ABAP CDS View Entity – A new kind of CDS view in ABAP release 7.55

0
11798

ABAP Core Data Services (CDS) is the implementation of the general CDS for ABAP. It defines semantic data models on standard tables and optimized them for the SAP HANA database. With ABAP release 7.55 (or) S/4HANA 2020, ABAP CDS view entity, a new type of CDS view. ABAP CDS view entities will replace the DDIC-based CDS views.

History

ABAP CDS view entity, first released with release ABAP 7.40, SP05. It is technically based on a CDS-managed DDIC view in the ABAP Dictionary. A CDS DDIC-based view is defined using the statement DEFINE VIEW.

At present, a CDS DDIC-based view (DEFINE VIEW) create a CDS-managed DDIC view in ABAP Dictionary. Using the CDS annotation @AbapCatalog.sqlViewName, a SQL database view is created upon activation.

As a result, additional maintenance is required and also impact on performance during activation. Following the limitations

  • CDS DDIC-based view, and the database view needs to be activated.
  • No strict syntax and annotation checks.
  • Additional annotation @AbapCatalog.preserveKey: true for the ABAP Dictionary SQL view.
  • Explicit client handling algorithm using annotation @ClientHandling.algorithm.
  • Long activation time especially with complex hierarichal views.

To overcome the limitations and for better performance CDS view entity are released.

ABAP CDS View entity

The CDS View Entity a new kind of CDS view. A CDS view entity is defined with the statement DEFINE VIEW ENTITY. Similar to the CDS DDIC-based views, CDS view entities are used to model data sources based on database tables or other CDS entities.

It offers more and improved features and most importantly, CDS-managed DDIC view or CDS DDIC-based view is NOT created upon activation.

Sample Code

@AccessControl.authorizationCheck: #NOT_ALLOWED 
DEFINE VIEW ENTITY demo_cds_view_entity 
 AS SELECT FROM scustom
 
    JOIN sbook 
    ON scustom.id = sbook.customid
     {
           scustom.id,
           scustom.name,
           sbook.bookid
     }

The above sample of the CDS views entity is clean and simple. No view-level additional annotations for SQL view name and client handling. They have the same syntax similar to the CDS DDIC-based views.

The CDS view entity can be used in ABAP programs using ABAP SQL, for example, SELECT * FROM demo_cds_view_entity INTO TABLE @itab …

They are improved version of CDS DDIC-based views. The possible data sources of CDS view entity can be

  • DDIC database tables, 
  • Another CDS view entities, 
  • CDS table functions, 
  • CDS hierarchies, or 
  • CDS DDIC-based views

ABAP CDS View entity – Advantages

CDS view entities are successor of CDS DDIC-based views and bring improved features such as

  • No CDS-managed SQL view is generated upon activation.
  • Implicit and automatic client handling, hence no annotation is required for client handling.
  • Strict syntax and annotation checks during activation.
  • Simplified handling of CDS extends
  • Faster activation and improved performance.

Restrictions

As the CDS view entity are new and more features will be added in future. Following are the restrictions at the time of writing this blog.

  • Select all elements from the data source using SELECT * is not supported in CDS view entities.
  • DISTINCT keyword and UNION clause is not yet supported.
  • It is not allowed to define a client field in the SELECT list.

Co-Exists

The existing classic ABAP CDS DDIC-based (DEFINE VIEW) view will co-exist along with the new CDS view entity (DEFINE VIEW ENTITY). It is recommended to use CDS view entities instead of CDS DDIC-based view due to technical improvements.

Conclusion

Congrats!! you successfully learned about the ABAP CDS view entity and its improved features. Stay tuned for more ABAP CDS tutorials. If you liked it ❤️, please share it! Thanks! ????

Continue Learning

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