In this post, we will take a look at ABAP CDS View Entity which was introduced With ABAP release 7.55.

CDS view entities will replace the CDS views. CDS views were first released in ABAP 7.40, SP05. These are declared using DEFINE VIEW and they create a DDIC / ABAP Dictionary view. The annotation @AbapCatalog.sqlViewName is used to specify the DDIC view name.

@AbapCatalog.sqlViewName: 'DEMO_CDS_PRJCTN'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_spfli
  as select from
    spfli
    {
      key spfli.carrid,
      key spfli.connid,
          spfli.cityfrom,
          spfli.cityto
    }

The SQL view is created/adjusted in the background during activation which impacts the activation performance. We also need to specify additional annotations for key preservation, client handling etc, but for me the real problem is that the CDS view name and SQL view name must have a different name – managing this becomes difficult at times.

Hence CDS View Entities. Here is one example.

@AccessControl.authorizationCheck: #NOT_REQUIRED
define view entity DEMO_CDS_VIEW_ENTITY_KEY
  as select from spfli
{
  key cityfrom,
  key cityto,
      carrid,
      connid
}

Important points to note are

  • It is defined with DEFINE VIEW ENTITY
  • It has similar syntax to CDS View
  • SQL / DDIC view is not created for the entities
  • The CDS view entity can be used in ABAP programs using ABAP SQL
  • The data source can be database table, CDS view, CDS view entity, CDS table function.

Advantages of CDS View entity

  • No SQL view is generated on activation – hence improved activation performance
  • Automatic client handling which is also implicit – no additional annotation is required
  • Strict syntax & annotation checks are applied during activation
  • Simpler to extend
  • New functionalities like regex replace, new operators like EXCEPT & INTERSECT are available from 7.56
  • SAP also provides a standard program RUTDDLS_MIGRATION_CANDIDATES to see if migration of CDS View to CDS View Entity is possible and in 7.56 we also get a program RUTDDLSV2MIGRATION that does the actual migration.

Restrictions

  • SELECT * is not allowed
  • Client field is not allowed in select list
  • DISTINCT and UNION clause were not allowed in version 7.55 but it allowed from version 7.56

As of now, both CDS View and CDS View entities will co-exist. However, if your ABAP version support entities – create entities as eventually we will need to replace the views with entities using the tools provided.

Most of the syntax remains the same so if you already understand CDS Views – you do not need to worry much, but if you do want to learn CDS Views head over to ABAP on HANA : CDS Views.

Visit ABAP on HANA series for Tutorials on CDS, AMDP, Eclipse, and ALV IDA.


If you like the content, please subscribe…

Join 4,012 other subscribers

Discovering ABAP YouTube Channel