A new generation of CDS views: CDS view entities
With ABAP release 7.55, a new type of CDS view is available: in official terminology, it’s called CDS view entity. And it has come to replace the “classic” CDS DDIC-based views that have been around for years.
This blog post provides the following information:
- Motivation: why has SAP developed a new type of CDS view?
- Key differences between DDIC-based views and CDS view entities
- Outlook: transition from DDIC-based views to CDS view entities
Motivation: why has SAP developed a new type of CDS view?
A CDS DDIC-based view is defined using the statement DEFINE VIEW. This kind of CDS view was first released with release 7.40, SP05 and it was for many years the only available kind of CDS view.
Since release 7.55, CDS view entities are available. They are defined using the statement DEFINE VIEW ENTITY. They have evolved from CDS DDIC-based views, serve the same purpose and have the same structure as their predecessor. But they offer several advantages over the “classic” CDS DDIC-based views, such as the following:
- No additional ABAP Dictionary view is created on activation.
- Improved performance during view activation.
- Optimization and simplification of syntax.
- Stricter syntax checks indicate problematic situations more explicitly, for example, annotation checks.
Key differences between DDIC-based views and CDS view entities
CDS view entities are a new and improved version of CDS DDIC-based views. Although very similar, CDS view entities are easier to use, and offer many small improvements and enhanced features.
Here are some principal ways in which CDS view entities differ from CDS DDIC-based views:
- There’s no DDIC view. The annotation @AbapCatalog.sqlViewName is not required and each view has only one name.
Please note that the name of the annotation is a bit misleading. Of course, a view entity has an SQL view on the database, but now the intermediate DDIC view is not needed any more.
- Fewer annotations are required. For example, client handling takes place implicitly and doesn’t require any development effort.
- Annotations are checked to ensure that only annotations defined as CDS objects in a CDS annotation definition can be used.
- Expressions can be nested within each other. Situations that previously required a view stack can now be implemented within a single view.
- Operand positions, such as the WHERE-clause, allow a greater variety of operands.
- Some features that haven’t been widely used are no longer supported in view entities. Here are some examples (but the list is not exhaustive):
- In DDIC-based views it is possible to assign alternative element names to elements of a SELECT-list using a name list. CDS view entities don’t support name lists.
- Domain fixed values in front of literals cannot be defined in CDS view entities.
- The syntax SELECT * to select all elements from the data source is supported in CDS DDIC-based views, but not in CDS view entities.
Additional features, such as typed literals to enhance type safety, and optimized buffer handling, are planned for future releases.
The following example compares a CDS DDIC-based view with a CDS view entity:
|CDS DDIC-based view||CDS view entity|
- The view entity doesn’t require the annotation @AbapCatalog.sqlViewName.
- The view entity doesn’t require the annotation @AbapCatalog.compiler.compareFilter: true, because the filter is implicitly and automatically compared.
- The view entity doesn’t require the annotation @ClientHandling.algorithm, since client handling takes place implicitly.
- The view entity doesn’t require the annotation @AbapCatalog.preserveKey: true, because there’s no ABAP Dictionary view attached to a CDS view entity.
- The view entity is defined using the statement DEFINE VIEW ENTITY.
For a comprehensive description of CDS view entities, refer to ABAP Keyword Documentation (F1 Help in SAP GUI and ADT).
Outlook: transition from CDS DDIC-based views to CDS view entities
Since ABAP Release 7.56, ABAP Platform 2021, it is possible to migrate existing DDIC-based views to CDS view entities. Details are described in the following blog post: A new generation of CDS views: how to migrate your CDS views to CDS view entities. Migration is voluntary and can be done to benefit from the enhanced functionality of CDS view entities. “Classic” CDS DDIC-based views are still supported, but not further developed. For new development scenarios, it is recommended to create only CDS view entities.
- ABAP Keyword Documentation (F1 Help, also available in SAP GUI and ADT)
- CDS view entities – the new CDS views – blog post about CDS view entities with further details
- A new generation of CDS views: how to migrate your CDS views to CDS view entities – blog post about the migration from CDS views to CDS view entities. Provides further details on the differences between CDS views and CDS view entities.