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
@AbapCatalog.preserveKey: true
@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.
@AbapCatalog.preserveKey: true
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: layer
@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
No comments:
Post a Comment