SAP CDS F1 DEFINE CUSTOM ENTITY



Get Example source ABAP code based on a different SAP table
  


• DEFINE CUSTOM ENTITY ABAP_CDS_DDL_STATEMENT

ABAP_CDS_DDL - DEFINE CUSTOM ENTITY

ABAP_SYNTAX
$[@entity_annot1$]
$[@entity_annot2$]
...
$[@ObjectModel.query.implementedBy : 'class_name'$]
$[DEFINE$] $[ROOT$] CUSTOM ENTITY custom_entity
$[parameter_list$]
element_list$[;$]

ABAP Addition
1 ... ROOT ...

What does it do?
Defines a CDS custom entity custom_entity in the CDS DDL. When a CDS custom entity is activated, its metadata is created but no other object instances are created on the database or in AS ABAP. The name custom_entity must comply with the naming conventions for dictionary types and can have a maximum of 30 characters.
@entity_annot can be used to specify optional annotations for the CDS custom entity.
The annotation @ObjectModel.query.implementedBy binds an ABAP class which implements an ABAP query. This query is not called by the ABAP runtime framework but by a framework like the RAP query engine.
parameter_list is used to declare a list of optional input parameters for the CDS custom entity.
element_list is used to declare elements, CDS associations, CDS compositions, and CDS-to-parent associations of the CDS custom entity.
A CDS custom entity can be used as a global structured type in ABAP programs. The entity is located in the namespace of all global types of an AS ABAP. The elements of the CDS custom 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 a CDS custom entity can be evaluated .



Latest notes:

A CDS custom entity cannot be used as a data source in other CDS entities or in ABAP SQL.
CDS custom entities can be used as values for the CDS annotations AssociationRef and ElementRef.
The annotation ObjectModel.query.implementedBy is mandatory when working in ABAP_SAP_BTP_ENV or ABAP_S4_CLOUD_ENV .
In the context of the ABAP RESTful Application Programming Model, custom entities are used as a data model basis for RAP unmanaged queries.
NON_V5_HINTS
No ABAP Dictionary DDIC structure visible in the tools for structures is created for a CDS custom entity.
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following DDL source code shows a CDS custom entity:
DDLS DEMO_SALES_SO_CUSTOM_ANALYTICS
ABAP_EXAMPLE_END
• ROOT ABAP_CDS_DEFINE_CUSTOM

ABAP Addition

What does it do?
In ABAP CDS, the keyword ROOT is used to define the CDS custom entity custom_entity as a root entity of the hierarchy of a business object. The following applies to the root entity:
There is exactly one root entity in the structure of a business object.
A root entity can have child entities defined as CDS compositions using the keyword COMPOSITION, but this is not mandatory. A root entity can also be a leaf entity.
A root entity does not have a parent entity. To-parent associations are not allowed in root entities.