SAP CDS CUSTOM ENTITIES



Get Example source ABAP code based on a different SAP table
  



ABAP_CDS - Custom Entities
A CDS custom entity is defined in the DDL source code of a CDS data definition using the statement DEFINE CUSTOM ENTITY in the CDS DDL of the ABAP Core Data Services (CDS). The name of the CDS custom entity must match the name of the DDL source code.
Purpose and use cases:
CDS custom entities allow developers to implement their own data provision using ABAP. Data retrieval is implemented via an ABAP class and performed at runtime. On CDS level, only an interface is defined, while the implementation of the logic is encapsulated in the application server artifact. Custom entities are used if data access cannot be done via means of SQL and the available CDS feature set and other CDS entity types. For example, custom entities can be used when
data is stored in non-relational storage, for example in a BLOB.
data is stored in SAP liveCache and access is done via ABAP APIs.
data cannot be computed by means of CDS due to additional application-server-side logic.
a data model can be defined via CDS views, but the DCL feature set is not sufficient to define the necessary authorizations.
Data retrieval is also possible using an http client.
In the context of the ABAP RESTful Application Programming Model, custom entities are used as a data model basis for RAP unmanaged queries.
A CDS custom entity represents all type properties of a CDS entity:
Metadata defined using CDS annotations
A structured type defined using an element list
Optionally, a parameter interface defined using input parameters
Any CDS associations, CDS compositions, or CDS to-parent associations exposed in the element list.
A CDS custom entity can be used as follows:
ABAP CDS
A CDS custom entity can be specified as the association target of a CDS association, CDS composition, or CDS to-parent association. A CDS association, CDS composition, or CDS to-parent association of this type can be exposed only and cannot be created as an instance of a join expression. Such associations can only be followed in Fiori OData scenarios where the RAP query engine (not SQL) is used to execute the query.
Since no SQL artifact is generated for CDS custom entities and the query is implemented in ABAP, a CDS custom entity cannot be used as a data source of SELECT statements or used by SQL path expressions in other CDS entities.
ABAP Programs
The structured type of the CDS custom entity is known in ABAP programs. Like the type of any CDS entity, it can be used after the addition TYPE.
BEGIN_SECTION VERSION 5 OUT The properties of the structured type can be evaluated using RTTI.
END_SECTION VERSION 5 OUT
A CDS custom entity cannot be used as a data source of SELECT statements or used by path expressions in AB_SQL .
Frameworks
In the context of the ABAP RESTful Application Programming Model, custom entities are used as a data model basis for RAP unmanaged queries. The ABAP query is in this case executed by a framework such as the RAP query engine.
The annotations of a CDS custom entity can be evaluated using the methods of the class CL_DD_DDL_ANNOTATION_SERVICE.
The parameters and the CDS associations of CDS custom entities can be evaluated by frameworks such as the RAP query engine.
An instance of a CDS custom entity is not created as a database object and client handling is not defined.

ABAP_FURTHER_INFO
Development guide for the ABAP RESTful Application Programming model, section Query.
ABAP Data Models development guide, section about CDS custom entities.



Latest notes:

Custom entities can be nodes in RAP business objects, for example root, parent and/or child nodes using ROOT and composition relationships.
NON_V5_HINTS
There is no DCL support for custom entities. If required, access control needs to be implemented manually in the query implementation class.
CDS metadata extensions are not supported for CDS custom entities.
ABAP_HINT_END