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 SQL view. The annotation @AbapCatalog.sqlViewName is not required and each view has only one name.
- 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
CDS view entities are the future of ABAP CDS. A migration tool that enables the migration from DDIC-based views to CDS view entities is under development. As soon as it is available, it is planned to migrate as many of the existing “classic” views to CDS view entities as possible (due to some incompatible changes, it is unlikely that all of the existing views will be migrated, though).
So, if you work with CDS views, familiarize yourself with CDS view entities. They’ll be around soon.
- 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