cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Update manually added Standard Fields to Standard ODATA APIs using Extended CDS view.

Sijin_Chandran
Active Contributor
0 Kudos

Hello SAP Gurus,

My query is exactly same as the below one,

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

But since there is no answer for this, am creating a post again.

We have added Standard PO Item field BEDNR to the CDS EntitySet responsible for Item details in /sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder

We are successfully able to use this newly added field for Data Fetch that is GET calls but during POST its not getting updated at the Table level.

 

@AbapCatalog.internal.setChange: 'FLDADD_NO_ASS_INFLUENCE'
@AbapCatalog.sqlViewAppendName: 'ZS_PO_API_EXT'
@EndUserText.label: 'Purchase Order API Extension'
extend view A_PurchaseOrderItem with Z_PO_API_EXT
{
  R_PurchaseOrderItem.RequirementTracking
}

 

Helpful pointers much appreciated on understanding where we could be missing on this.

Thanks,

Sijin

Accepted Solutions (1)

Accepted Solutions (1)

Sijin_Chandran
Active Contributor
0 Kudos

Hello all, 

We finally got it resolved, below is the solution:

The solution lies with Enhancing/Extending the Standard CDS 'E_PurchasingDocumentItem' with the fields which are not available as part of Standard API, and this will enable the Transactional capabilities for the fields added using this Extension CDS view.

 

@AbapCatalog.internal.setChange: 'FLDADD_NO_ASS_INFLUENCE'
@AbapCatalog.sqlViewAppendName: 'ZS_PO_BEDNR'

extend view E_PurchasingDocumentItem with Z_PO_BEDNR

{
  Persistence.bednr as RequirementTracking
}

 

So, in the nutshell, considering this example case i.e. BO Root View 'A_PurchaseOrder' or we can say API '/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/A_PurchaseOrder', if we need to add Fields in the API just for GET (QUERY and READ) Operations at ITEM level then just Enhancing 'A_PurchaseOrderItem' with the needed fields will work. 

But, on top of this if we need to add Transactional capabilities(remaining CUD operations i.e. CREATE, UPDATE and DELETE) as well on the newly added fields then we need to Enhance CDS View 'E_PurchasingDocumentItem' in a similar manner.

NOTE: This approach is only needed for missing Standard Fields in the API/CDS/BusinessObjects related Structures. For adding Custom Fields we should always resort to the Standard Fiori app meant for this purpose i.e. Custom Fields and Logic  , it will automatically take care of updating all the needed CDS Views and Entities.

Thanks,

Sijin

Answers (1)

Answers (1)

Mikhail_Minakov
Explorer
0 Kudos

I suppose you have to redefine PATCH method of class CL_API_PURCHASEORDER_P_DPC_EXT implementing the modify code for new field.

More details Extending an OData Service Using Service Builder 

Sijin_Chandran
Active Contributor
0 Kudos
Hello Mikhail, We were finally able to find the solution for this with minimalistic coding approach. I have updated the same as solution, you can have a look. Thanks, Sijin