Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Masaaki
Advisor
Advisor
Updated on 20 Jan 2023:

  • Not recommended to use @Analytics.technicalName


Updated on 18 Jan 2023:

  • The mapping between CDS View name and Tech name can bee checked  on the view "RSODP_ABAP_CDS_ODPNAME" or class CL_RSODP_ABAP_CDS_BW_NAME_MAP->CL_RSODP_ABAP_CDS_BW_NAME_MAP.

  • Dependency Analyzer in ADP cannot work for 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>'. but it is not recommended.

  • 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
{
}

 

VDM created with CDS View Entity.

C_EWM_WarehouseTaskQ_2

 

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 mapping between CDS View name and Tech name can bee checked  on the view "RSODP_ABAP_CDS_ODPNAME" or class CL_RSODP_ABAP_CDS_BW_NAME_MAP->CL_RSODP_ABAP_CDS_BW_NAME_MAP.

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

 



Not recommended to use technicalName:

in general @Analytics.technicalName shouldn’t be used, since the uniqueness of the name isn’t checked. It is possible that someone creates a CDS view with the name given in Analytics.technicalName of another view. Then both views have the same 2C Name in Analytics. In this case the later created view will not be available in analytics.b

Therefore we recommend to use @Analytics.technicalName only if you migrate a view to a view entity. When migrating you must use the former SQLViewName as technical Name to keep the 2C name in analytics.

 

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).

  • Dependency Analyzer in ADP cannot work for CDS View Entity.


 

Thanks!
10 Comments