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
1,480

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

View Entire Topic
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

FabrizioD
Discoverer
0 Kudos
Hello Sijin,
FabrizioD
Discoverer
0 Kudos

Hello @Sijin_Chandran
can you please, explain this: @AbapCatalog.internal.setChange: 'FLDADD_NO_ASS_INFLUENCE'
And how do you know names to use (Es. A_PurchaseOrderItem, E_PurchasingDocumentItem,R_PurchaseOrderItem, Persistence)?

I tried to expand API Sales Order, on S4HANA ON-PREMISE system, adding a standard field missing on API_SALES_ORDER_SRV, following your steps, but doesn't work. I try to add OrderID (VBAP-AUFNR).


@AbapCatalog.sqlViewAppendName: 'ZSD_EXT'
@EndUserText.label: 'Extension view for SalesOrder'
extend view A_SalesOrderItem with ZA_SalesOrderExt
//extend view E_SalesDocumentItemBasic with ZA_SalesOrderExt
{
I_SalesOrderItem.OrderID
}

@AbapCatalog.sqlViewAppendName: 'ZE_SD_EXT'
@EndUserText.label: 'Extension view for SalesOrder'
extend view E_SalesDocumentItemBasic with ZE_SALESORDEREXT
{
Persistence.aufnr as OrderID
}

Actually I can see the new field using GET method, but I cannot use it for POST/PATCH. Filling the new field the order is correctly created, but the field is empty.

POST Order by Postman
Screenshot 2024-09-13 180518.png

GET Order created by Postman

Screenshot 2024-09-13 180500.png

Get order saved using VA01 with OrderID filledScreenshot 2024-09-13 182830.png

 

Thank a lot!

Fabrizio

Sijin_Chandran
Active Contributor
0 Kudos
@FabrizioD rather than focusing on the naming convention, please dig the BO ( Business Object ) if the standard REST API you are trying to tweak is built using RAP model.
josua
Explorer
0 Kudos
Hello Sijin,
josua
Explorer
0 Kudos

Hello @Sijin_Chandran ,

how do you know which correct CDS needs to be extended regarding adding standard fields in API_Purchase_Order, which in this case you enhance the 'E_PurchasingDocumentItem'.

In my case, I would like to add standard field in API API_CUSTOMER_RETURN_SRV, in item level; field MatlAccountAssignmentGroup (VBAP-KTGRM) to work in POST method. I tried with extending CDS View A_CustomerReturnItem, however only GET operations works like as you mention earlier. Any advice?

Sijin_Chandran
Active Contributor
0 Kudos
Hello @josua , As I replied above, you need to dig inside the BO, starting from the Service Definition you need to Expand and dig deep level to explore how the CURD operations are carried out. In our case when we checked deep then we found out that this E_ view was the one which needs to be enhanced for enabling Update operation. Also, if you create a Custom Fields and Logic then also all the Entire BO Objects gets captured and you can have a look there.