Skip to Content
Technical Articles

CDS View Entity

Purpose of this blog

As of ABAP 7.55, a new type of CDS entity, CDS View entity is available, in which DDIC SQL View is no longer created together, so the activation time is optimized (about a half time in an internal test).

Details about CDS View entity are explained in the following blogs.

 

The purpose of this blog is to show the created CDS view entities including Analytic Query, Extended entity, Annotate Entity in the system.

 

Test system

  • S/4HANA On premise 2020 Initial shipment stack
  • ABAP Platform Initial shipment stack (SAP_BASIS 755/0000 with SAP Kernel 781 patch19).

 

Summary

  • DDIC SQL View is not created but View is generated in database layer only. The name of the view is the same as CDS View entity name.
  • To extend CDS View entity, Extend entity is used in which DDIC SQL View is not created either.
  • To add annotations to the CDS View entity, Annotate entity should be used.
  • Analytic Query name is “2C<CDS View entity>” normally, not “2C<SQL View name>, but can be renamed with annotation @Analytics.technicalName: ‘<ShortUniqueIdentifierForTheView>’.
  • CDS View can work as the ODP Data source to send data to BW or the data source in ETL tools like SDI.
  • CDS View entity can use CDS View as the source of CDS View entity and vice versa.

 

Definitions of CDS View entity and relevant views

Interface View: ZI_ACDOCA10


@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'ACDOCA'
@Analytics: { dataCategory: #CUBE,dataExtraction.enabled: true }
@OData.publish: true
@Metadata.allowExtensions: true
define view entity ZI_ACDOCA10
  as select from acdoca
  association [0..1] to I_Segment as _Segment on acdoca.segment = _Segment.Segment
{
  rldnr,
  rbukrs,
  gjahr,
  ryear,
  poper,
  fiscyearper,
  periv,
  ktopl,
  racct,
  kokrs,
  prctr,
  @ObjectModel.foreignKey.association: '_Segment'
  segment,
  matnr,
  rbusa,
  bstat,
  rtcur,
  rhcur,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'rtcur'
  tsl,
  @DefaultAggregation: #SUM
  @Semantics.amount.currencyCode: 'rhcur'
  hsl,
  _Segment
}


 

Extend entity: ZX_ACDOCA10

Field kunnr with master view I_Customer, Product type with I_Product._ProductType are added with Extend View entity.


extend view entity ZI_ACDOCA10 with
association [0..1] to I_Customer as _Customer on acdoca.kunnr = _Customer.Customer
association [0..1] to I_Product  as _Product  on acdoca.matnr = _Product.Product
{
  @ObjectModel.foreignKey.association: '_Customer'
  acdoca.kunnr,
  @ObjectModel.foreignKey.association: '_ProductType'
  _Product.ProductType,
  _Customer,
  _Product._ProductType
}

 

Analytic Query: ZC_ACDOCA10

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'ZC_ACDOCA10'
@Analytics.query: true
define view entity ZC_ACDOCA10
  as select from ZI_ACDOCA10
{
  //ZI_ACDOCA10
  rldnr,
  rbukrs,
  gjahr,
  ryear,
  poper,
  fiscyearper,
  periv,
  ktopl,
  @AnalyticsDetails.query.axis: #ROWS
  racct,
  kokrs,
  prctr,
  segment,
  matnr,
  rbusa,
  bstat,
  rtcur,
  rhcur,
  kunnr,
  @AnalyticsDetails.query.display: #KEY_TEXT
  ProductType,
  tsl,
  hsl,
  /* Associations */
  //ZI_ACDOCA10
  _Segment
}

 

Annotate entity: ZM_ACDOCA10

@Metadata.layer: #CORE
annotate entity ZI_ACDOCA10 with
{
  @EndUserText.label: 'SegmentTxt'
  segment;
}

DB hint cannot be added with Annotate entity but can be done with Annotate View.

Target of Annotate entity is not only CDS View entity but other CDS objects like CDS Projection View, Table Function.

Annotate View: ZM_ACDOCA20

@Metadata.layer #CORE
@Consumption.dbHints: ['USE_OLAP_PLAN ']
annotate view ZI_ACDOCA10 with
{
}

 

Object checks

SQL View in database layer

Although DDIC SQL View is not created, the database view is created internally in HANA DB layer as shown below.

Run the following query with Transaction DBACOCKPIT > Diagnostics > SQL Editor

 

select top 100 * from ZI_ACDOCA10

Result

 

Run Analytic Query

Analytic Query is a Consumption View type which works almost the same as BW Query. See the blog for more about Analytic Query (CDS Query).

The name of the Analytic Query is “2C<CDS View entity name>” (It can be renamed with annotation @Analytics.technicalName: ‘<ShortUniqueIdentifierForTheView>’). In CDS View, the Analytic Query name is “2C<SQL View name>”.

The query “2CZC_ACDOCA10” can be run with the Transaction RSRT.

 

 

Data Source

ZI_ACODOCA10 is set as Data Source (@Analytics.dataExtraction.enabled: true), so it works as ODP data source to send data to BW, or can be used as the data source in the ETL Tools like Data Intelligence and Smart Data Integration. See the blog for more about ODP.

In BW system, run Replicate the Data Source (Transaction RSA1 > Data Source, and select BW system. in the context menu in the right side, select Replicate Data Source). Select the CDS View entity name (“ZI_ACODCA_F”). “_F” is added as suffix as is the transaction data.

Now the CDS View entity is added as ODP Data Source.

Select change in the context menu of the ODP Data Source and activate it.

 

Go to preview tab and run “Read Preview Data”.

 

 

CDS View entity using CDS View as the source and vice versa

CDS View and CDS View entity can be nested: CDS View can use CDS View entity as the source and vice versa.

CDS View Z_VBAPVBEP2

@AbapCatalog.sqlViewName: 'ZVBAPVBEP2'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Z_VBAPVBEP2'
define view Z_VBAPVBEP2
  as select from Z_VBAPVBEP
{
  //Z_VBAPVBEP
  vbeln,
  posnr,
  etenr,
  netwr,
  waerk
}

CDS View entity Z_VBAPVBEP3

@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Z_VBAPVBEP3'
define view entity Z_VBAPVBEP3
  as select from Z_VBAPVBEP2
{
  //Z_VBAPVBEP2
  vbeln,
  posnr,
  etenr,
  @DefaultAggregation: #SUM
  @Semantics: { amount : {currencyCode: 'waerk'} }
  netwr,
  waerk
}

 

Others

  • The View created with Key user Tool “Custom CDS views” is CDS View, NOT CDS View entity (future plan).
  • is not possible at the moment (future plan).

 

Thanks!

Be the first to leave a comment
You must be Logged on to comment or reply to a post.