cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Update Additional Fields in Extended CDS view for Standard ODATA API.

0 Kudos

Hi,

We have to add 3 additional fields from EKPO table to the PO Item node in the SAP standard Purchase Order API (which is published in SAP API Hub). For this we need to extend the Standard CDS view A_PurchaseOrderItem.

First, we created a custom CDS view which fetches the 3 fields LEBRE (InvoiceIsServiceReceiptBased), KZABS (IsOrderAcknowledgementRequired) and LABNR (OrderAcknowledgementNumber) from EKPO table as below:

@AbapCatalog.sqlViewName: 'ZEKPO'

@AbapCatalog.compiler.compareFilter: true

@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #NOT_REQUIRED

@EndUserText.label: 'EKPO Table extra fields'

@ObjectModel.createEnabled:true

@ObjectModel.updateEnabled:true

define view Z_EKPO

as select from ekpo

{

key ebeln as PurchaseOrder,

key ebelp as PurchaseOrderItem,

lebre as InvoiceIsServiceReceiptBased,

kzabs as IsOrderAcknowledgmentRequired,

labnr as OrderAcknowledgmentNumber

}

Then, we created the extended CDS view for A_PurchaseOrderItem and created an association from the Extended CDS view to the custom CDS view as shown below:

@AbapCatalog.sqlViewAppendName: 'ZPOITEM'

@EndUserText.label: 'API PurchaseOrderItem Extension'

@VDM.viewExtension: true

extend view A_PurchaseOrderItem with Z_A_PurchaseOrderItem

association [1..1] to Z_EKPO as _ekpo on $projection.purchaseorder = _ekpo.PurchaseOrder

and $projection.purchaseorderitem = _ekpo.PurchaseOrderItem

{

_ekpo.InvoiceIsServiceReceiptBased,

_ekpo.IsOrderAcknowledgmentRequired,

_ekpo.OrderAcknowledgmentNumber

}

After doing this, we are able to see the additional fields in the PO Item node in the SAP standard Purchase Order API and we are getting the values of these 3 additional fields in both GetEntity and GetEntityList, along with other standard fields. But when we are trying to update the PO Item using PUT/PATCH only the standard fields are getting updated, not the Extended CDS view fields. How can we enable updation of the Extended view fields also in this case? Thanks.

View Entire Topic
Sijin_Chandran
Active Contributor
0 Kudos

Hello,

The solution for this is that in addition to this structure you need to Enhance CDS View 'E_PurchasingDocumentItem' as well.

And one more thing here, you have wrongly Extended 'A_PurchaseOrderItem' for the purpose of adding the Standard field , you should add it using Standard CDS view 'R_PurchaseOrderItem' , almost all the Standard fields are available in this CDS Entity.

Example:

@AbapCatalog.sqlViewAppendName: 'ZSEKPO_EXT'
@EndUserText.label: 'Extension for PO Item'
extend view A_PurchaseOrderItem with ZEKPO_EXT
{
    R_PurchaseOrderItem.RequirementTracking
}

Please check the below thread for detail.

https://community.sap.com/t5/technology-q-a/unable-to-update-additional-fields-in-extended-cds-view-...

Thanks,

Sijin