cancel
Showing results for 
Search instead for 
Did you mean: 

Update entity with Association, navigation in SAPUI5 and SAP GATEWAY

arindam_samanta
Participant
0 Kudos

Hello Experts,

In my SAPUI5 application, I have one like below format:

For the above mentioned data, I have created my ODATA entity set with association. My primary entity is EMP. My dependent entities are ASSIGNMENT, EMPINFO, EMPEX where ASSIGNMENT is kind of array.

I have redefined the method CREATE_DEEP_ENTITY. Its working fine. Now my question is:

I would like to update the data which is created through the method CREATE_DEEP_ENTITY.

To do so, need guide or suggestion. What is the best way to achieve this? Please help me on this.

If any doubt in my requirement, please ask me.

Thanks,

Arindam.

Accepted Solutions (0)

Answers (1)

Answers (1)

maheshpalavalli
Active Contributor
0 Kudos

HI Arindam Samanta

Simply, next time send the data using the deep format only but check in that method if the key is passed, then it is update else if no key is passed then it is create.

But the best way would be to call the individual create or update method via the batch(if it is odata v2 model by default it groups all the create,update and delete operation). Then in the backend instead of create deep, use the changeset process methods where you will get all the individual create, update and delete requests in seperate rows and from there you can write the save logic. there are couple of blogs out there regarding the changeset process, one such link below:

https://blogs.sap.com/2018/05/06/batch-request-in-sap-gateway/

BR,
Mahesh

arindam_samanta
Participant
0 Kudos

Hello Mahesh,

Thanks for your response and its really helpful. Can you please help me how to make the same requirement in SAPUI5?

What should be the code for same thing? How we can pass the data from SAPUI5 to my ODATA/GATEWAY?

Is there any helpful link?

Thanks,

Arindam.

maheshpalavalli
Active Contributor
0 Kudos

It's simple, you need to use odata v2 model, which by default batches the data. On click of save, call the create method of odata v2 model multiple times in a loop or in your way for multiple entitysets. Then by default the requests are batched and sent in one request.

So in the backend, you will use the changeset process method to get all the rows.

But like I said, if you dont want to rewrite the whole process, simple use the create deep entity only but differentiate the data in the createdeep entity method based on the key. if it is filled it is update else it is create. key means, like if you are updating sales order, it is sales order number

BR,

Mahesh