ABAP CDS Custom Entity in ABAP 7.55 and Restful ABAP Programming Model


ABAP CDS Custom entity is defined using the statement DEFINE CUSTOM ENTITY. A CDS custom entity is a non-SQL (or) no-SELECT CDS entity introduced with ABAP release 7.55 and S/4HANA 2020 FPS00. In this blog post, you will learn about ABAP CDS custom entities and their features.

Let’s get started…


ABAP CDS entities are ABAP repository objects used to define data models on the standard tables, particularly the SAP HANA database. It enables code push down through which code optimization is achieved.

In ABAP release 7.55, we can create the following 7 types of ABAP CDS entities.

CDS View EntitiesImproved version of classic CDS DDIC-based views.
CDS Projection ViewsA direct projection of an underlying any CDS entity.
CDS Custom EntitiesThey are used for data models whose runtime is implemented manually.
CDS HierarchiesUsed to create a hierarchy from a data source.
CDS Table FunctionsImplemented using AMDP Class and functions.
CDS Abstract EntitiesDescribes type attributes and database object instances are created.
CDS DDIC-based viewsBased DDIC based database views in ABAP Dictionary.

Here we will be discussing ABAP CDS Custom Entities.

ABAP CDS Custom Entity

A CDS Custom entity is defined using the statement DEFINE CUSTOM ENTITY in the DDL source code using ADT – eclipse-based IDE. The runtime is implemented manually using the ABAP class.

Yes, you heard it correctly!! In other CDS entities, the selection logic to retrieve the data from a data source is defined in DDL source code, but ABAP CDS custom entities do not have a SELECT statement.

ABAP CDS custom entities are non-SQL (or) no-SELECT CDS entities whose runtime is implemented manually by adding an annotation @ObjectModel.query.implementedBy. It requires an ABAP class that implements the select method of the interface IF_RAP_QUERY_PROVIDER.

The CDS Custom entity is available in both SAP Business Technology Platform( SAP BTP ) ABAP Environment and on-premise S/4HANA 2020 FPS00 as part of ABAP Restful programming Model(RAP).

Syntax of CDS Custom Entity

@EndUserText.label: 'Display Supplier List'
@ObjectModel.query.implementedBy: 'ABAP:ZCL_SUPPLIER_LIST'
@Search.searchable: true

define custom entity ZCDS_C_SUPPLIER_LIST  
  key Supplier      		: supplier_id;  
      CompanyCode   		: bukrs;
      BusinessParnter 		: bu_partner;
      PruchasingOrganisation 	: ekorg;  

The above DDL source code shows the syntax of a CDS Custom Entity view:

  • CDS custom entities do not have a SELECT statement.
  • The runtime of a CDS custom entity is implemented manually in an ABAP class ZCL_SUPPLIER_LIST
  • The class ZCL_SUPPLIER_LIST is referenced in the CDS custom entity using the annotation @objectModel.query.implementedBy.
  • The elements of the CDS custom entity are specified and separated by a semicolon. The final element must also be followed by a semicolon.
  • Optional, you can add input parameters to the custom entity.

Query implementation class

Following the ABAP Class syntax for custom entity implementation. To complete the implementation the SELECT method of the query provider interface IF_RAP_QUERY_PROVIDER is refined with data retrieval logic.

Note: Before activating the CDS custom entity, we need to create an ABAP class that implements the interface IF_RAP_QUERY_PROVIDER. 


    INTERFACES if_rap_query_provider.

  METHOD if_rap_query_provider~select.

   "abap code goes here to retrived the data...


When to use?

The CDS custom entity is used to define data models whose runtime is implemented manually. The signature of the CDS entity is also separated from the implementation. The following are some of the use cases

  • Data can’t be retrieved using ABAP CDS views because of additional business logic which can’t be done with the SELECT ON statement.
  • Data has to retrieved from the local database tables along with some partial data from other remote services.


Congrats!! you have successfully learnt about Custom CDS entity. This is just an introductory blog post and we will be writing more tutorials on this topic. If you liked it ❤️, please share it! Thanks! 🙏

Please feel free to comment and let us know your feedback. Subscribe for more updates.

Stay Connected