Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

XSA - OData - Merge vs Put - ".update" function ISSUE

cfbruce
Explorer
0 Kudos

Hi, I'm migrating from XSC to XSA (Cloud), and running into an issue with my oDataModels where I typically write ".update", but seeing as "MERGE" is not supported, what is the recommended work around? If I were to use "PUT" this by definition would replace the row with my payload, but I only want to change the "Deltas".

Another solution is to write a procedure, but this is very challenging as I'd have to do this for every table definitions, meaning quite a bit of work + very challenging to manage the procedure and any table updates.

Can you advise on the workaround?

  • SAP Managed Tags:
1 ACCEPTED SOLUTION

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,
I'm not familiar with XSC nor XSA, but from OData perspective, I would recommend to use PATCH.
I think this suits your requirements.
If you want to change only 1 property, you send only this 1 changed property to the OData-server.
On serverside, the OData lib/fwk has to take care to "merge" the reduced payload with the rest of the entry/entity.
This is also recommended due to better network usage.

Kind Regards,
Carlos

  • SAP Managed Tags:
3 REPLIES 3

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,
I'm not familiar with XSC nor XSA, but from OData perspective, I would recommend to use PATCH.
I think this suits your requirements.
If you want to change only 1 property, you send only this 1 changed property to the OData-server.
On serverside, the OData lib/fwk has to take care to "merge" the reduced payload with the rest of the entry/entity.
This is also recommended due to better network usage.

Kind Regards,
Carlos

  • SAP Managed Tags:

0 Kudos

Thanks Carlos. I'm referring to Hana XS Classic vs Hana XS Advanced. In any case, do you know how you'd specify "PATCH" on the odatamodel definition - here's how I use instantiate it - https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.model.odata.v2.ODataModel%23constructor ?

  • SAP Managed Tags:

CarlosRoggan
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Bruce, thanks for accepting!
I see now your question has turned into a UI5 question...
And here I'm not familiar either.
I see from your link, that you have OData V2 implementation? Yes, I think coming from XSC it is obvious.
Hm, OData V2 supports PATCH as well (whereas in V4 it is the default, and PUT is deprecated) but as far as I can see in the docu, the UI5 ODataV2 model doesn't support Patch. Seems that only Merge and PUT are supported (where MERGE seems to be the default setting).
Do you have a chance to add merge support to your OData-service implementation?
In the impl, you would first call the GET method, to obtain the full data of the entry. Then manually replace the properties that come with the MERGE request. Then call the normal UPDATE on the DB layer (or whatever)
Kind Regards,
Carlos

  • SAP Managed Tags: