Skip to Content

Group update requests when syncing in SAP MDK

Hi Experts,

I have created an offline MDK app where I show some orders and corresponding items. I have enabled edit functionality for items using a form cell page and created an odata action of type UpdateEntity to save the data. When I click on sync, the data is uploaded to the backend correctly. But with this approach, for each item a separate request gets sent. So for the same order, if I edit two items, two requests get sent.

In order to avoid lock issues, and update the order at once, how can I group all the update requests for the order or everything together, so that I can process them as one from the backend.

I want a similar functionality like batch changeset or create deep entity when we create Fiori apps. Please be kind enough to advice on steps I need to follow to achieve this.


Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 09, 2020 at 08:47 AM

    Dhanika Wickramaratne

    In MDK, this needs to be done differently as MDK does not have “Model” concept like what UI5 has (i.e. ODataModel) that allow you to make the changes in the runtime model object before “submitting” the changes to the OData backend (offline or online) as batch changeset. To do that in MDK, you will need to sort of create your own version of “Model” implementation that will temporarily hold the changes until you are ready to commit all of them in a change set. You can either track them with your own JavaScript global object or use PageProxy's ClientData to store and track changes before submitting them in ChangeSet. If you use a page's ClientData, the data will be destroyed when you close the page, so you should choose the page that won't be closed until the changeset is submitted e.g. the main page of your app.
    And please do note that if you do so, the changes won't reflected in the UI until you have submitted the changeset.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 02, 2020 at 11:10 AM

    Dhanika Wickramaratne

    When you call UpdateEntity in your offline app, Item 1, Item 2 get saved locally and those changes get recorded in a RequestQueue database. When you trigger offline upload action, the content of the request queue database get uploaded/flushed to Mobile Services (MS). MS will then REPEAT the exact same request to the backend, E.g.,

    • Update item 1
    • Update item 2

    It's still 2 separate requests to the backend when you upload.

    MDK supports ChangeSet action, have a look at this documentation.

    Add a comment
    10|10000 characters needed characters exceeded