ABAP CDS - DEFINE ABSTRACT ENTITY
[DEFINE] ABSTRACT ENTITY cds_entity
Defines an abstract CDS entity cds_entity in CDS DDL. When an abstract CDS entity is activated, its metadata is created but no other object instances are created on the database or in AS ABAP. The name cds_entity must comply with the naming conventions for dictionary types and can have a maximum of 30 characters.
- parameter_list is used to declare a list of optional input parameters for the abstract CDS entity.
- element_list is used to declare elements and CDS associations of the abstract CDS entity.
An abstract CDS entity can be used as a global structured type in ABAP programs. The entity is located in the namespace of the
data types in ABAP Dictionary and in the namespace of the global
object types in the
class library. The elements
of the abstract CDS entity define the components of the global structured type that can be referenced
in ABAP programs using
TYPE. As is the case for any CDS entity, the annotations of an abstract CDS entity can be evaluated.
- An abstract CDS entity cannot be used as a data source in other CDS entities or in ABAP SQL.
- The DDL source code of an abstract CDS entity must have the same name as this entity.
The following DDL source code shows an abstract CDS entity:
@DemoAnno.vAnnot1: 'Some annotation'
define abstract entity demo_cds_abstract_entity
key col1 : abap.char(3);
col2 : abap.int4;
col3 : abap.string;
col4 : demo_char_text;
The program DEMO_CDS_ABSTRACT_ENTITY demonstrates the following:
- The structure of the abstract CDS entity can be evaluated using RTTI methods.
- The annotations of the abstract CDS entity can be evaluated using the class CL_DD_DDL_ANNOTATION_SERVICE.
- The structure of the abstract CDS entity can be used as a data type in the ABAP program.