cancel
Showing results for 
Search instead for 
Did you mean: 

CDS Datasource Extensions?

steven_clayton2
Explorer

With the old SAPI Datasources we can enhance them using custom appends and exit/badi code or for LO datasources we can choose additional pool fields via the LBWE Logistics cockpit etc..

How do we enhance the newer CDS based Datasources? Take for example C_PurchaseOrderItemDEX. Is it just a case of creating your own CDS Extension? Or Extensions since the underlying CDS view I_PurchaseOrderItemAPI01 might also need an extension to supply selected additional fields?

Like many CDS views, I_PurchaseOrderItemAPI01 has an Extension association included in it. Should this inbuilt Extension Association be used?

If so, do we following the steps in the below blog, which deals with extending COPA CDS query views (approach recommended in note 3005736)?

https://blogs.sap.com/2018/01/11/extending-cds-queries-with-co-pa-ww-fields/

This would mean creating an Extend view on E_PurchasingDocumentItem, one on I_PurchaseOrderItemAPI01 and finally one on C_PurchaseOrderItemDEX?

Is there a best practice approach for enhancing these SAP Standard CDS based DataSources?

View Entire Topic
MKreitlein
Active Contributor
0 Kudos

Hello Steven,

yes, best way is to use this already available extension. Here one of my examples:

In SD we included new Subtotal Amounts into VBRP and so we created one Extend view for the standard view:

C_BillingDocItemBasicDEX_1

See:

@AbapCatalog.sqlViewAppendName: 'YSDEBILLITMD'
@EndUserText.label: 'Extend E_BillingDocumentItem VBRP Subtotals'
extend view C_BillingDocItemBasicDEX_1 with YSD_INV_E_SDBILLITEMDEX1 {
_ExtensionItem.Subtotal7Amount,
_ExtensionItem.Subtotal8Amount,
_ExtensionItem.Subtotal9Amount,
_ExtensionItem.Subtotal10Amount

In that way you create your own in Y- or Z-namespace and can extend the regular C_ one.

This works because the standard view has alreay an extension:

define view C_BillingDocItemBasicDEX_1
as select from I_BillingDocExtdItemBasic as BillingDocumentItemBasic
//Extension
association [0..1] to E_BillingDocumentItem as _ExtensionItem

I hope this helps.

BR, Martin

steven_clayton2
Explorer
0 Kudos

Thanks Martin.

Did you also manually create an extension for E_BillingDocumentItem? Or was this handled in the Custom Fields and Logic Fiori App when the additional subtotals fields were added to VBRP?

MKreitlein
Active Contributor
0 Kudos

Hello Steven,

no, the view E_BillingDocumentItem has not been extended... this looks like:

define view E_BillingDocumentItem as select from vbrp as Persistence {
key Persistence.vbeln as BillingDocument,
key Persistence.posnr as BillingDocumentItem
}

Only the table got enhanced, that was all:

BR, Martin

steven_clayton2
Explorer
0 Kudos

Thanks Martin, I'll give that a try.

But where does the field re-naming take place? YYKZWI07 becomes Subtotal7Amount somewhere. Isn't there an extend view for E_BillingDocumentItem that does this? Something like this?

extend view E_BillingDocumentItem with ZE_BillingDocumentItem {

Persistence.yykzwi07 as Subtotal7Amount,

Persistence.yykzwi08 as Subtotal8Amount,

Persistence.yykzwi09 as Subtotal9Amount

Persistence.yykzwi10 as Subtotal10Amount

}

MKreitlein
Active Contributor

Hello Steven,

I did another check ... it is already 6 months ago 🙂

You are right... there is one more:

@AbapCatalog.sqlViewAppendName: 'YBIEVBRPZSUM'

@EndUserText.label: 'Erweiterung View E_BillingDocumentItem'

extend view E_BillingDocumentItem with YBI_CDS_E_VBRP_ZWISUM {

yykzwi07 as Subtotal7Amount,

yykzwi08 as Subtotal8Amount,

yykzwi09 as Subtotal9Amount,

yykzwi10 as Subtotal10Amount}

steven_clayton2
Explorer
0 Kudos

Perfect! Thanks Martin