Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
AndreaUS
Product and Topic Expert
Product and Topic Expert
113,782

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:

  1. Motivation: why has SAP developed a new type of CDS view?
  2. Key differences between DDIC-based views and CDS view entities
  3. 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.
  • Overhauled buffer handling by means of CDS tuning objects offers more flexibility (see Buffering CDS View Entities | SAP Blogs for further details).
  • Overhauled extension concept with CDS view entity extends (EXTEND VIEW ENTITY) offers much faster activation performance, see ABAP Core Data Services: New syntax for extending CDS entities | SAP Blogs for further details.
  • 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.
    • The syntax SELECT * to select all elements from the data source is supported in CDS DDIC-based views, but not in CDS view entities.
    • Domain fixed values in front of literals cannot be defined 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 viewCDS view entity

@AbapCatalog.sqlViewName: 'DEMO_CDS_JOIN'

@AbapCatalog.compiler.compareFilter: true

@ClientHandling.algorithm: #SESSION_VARIABLE

@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #NOT_ALLOWED 

define view demo_cds_scarr_spfli

  as select from spfli

    join scarr on scarr.carrid = spfli.carrid

{

  key spfli.carrid     as id,

  key scarr.carrname   as carrier,

  key spfli.connid     as flight,

        spfli.cityfrom as departure,

        spfli.cityto   as destination

}




.

.

.

.

@AccessControl.authorizationCheck: #NOT_ALLOWED

define view entity demo_cds_scarr_spfli_2

as select from spfli

      join scarr on scarr.carrid = spfli.carrid

    {

      key spfli.carrid      as id,

      key scarr.carrname    as carrier,

      key spfli.connid      as flight,

             spfli.cityfrom as departure,

             spfli.cityto   as destination

    }

Differences:

  • 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 supported, but not further developed. For new development scenarios, it is recommended to create only CDS view entities.
Info: SAP will continue to support classic CDS DDIC-based views. CDS DDIC-based views will not be retired, and customers will not be forced to use CDS view entities. SAP protects investments.

Update May 2022: Since ABAP release 7.88, CDS view entities are feature complete. An overview of all new features, improvements, and differences is provided in the blog series CDS view entities are feature complete. Overview of new features, improvements, and differences | SA....

Further information:

 

94 Comments
Labels in this area