SAPUI5 & ODataModel V2: Find out which request groups have pending requests

Viewed 384

I'm using ODataModel V2 and have 3 deferred request groups. If there are requests for more than one group I have to submit them in specific order. Therefore I need to know which group has pending requests. Is there already a smart method for?

Definition of my request groups

  • Entry creations via Method "createEntry" are collected into group "create"
  • Entry deletions via Method "remove" are collected into group "delete"
  • Everything else is collected into group "changes"

What I've found out so far

  • The "delete" group is easy, if there is one, it's contained in "oDataModel.mDeferredRequests".
  • The "create" group is only contained in "mDeferredRequests" if there are also requests for the "changes" group. So if it's contained in "mDeferredRequests" I know that there are requests for both "create" and "changes".

But if there are only requests for either "create" or "changes" I've found only the way via method "getPendingChanges". The newly created entities have the groupId included within the metadata like so:

NewObject('id-123456-00'):
    Attribute: "123"
    __metadata:
        created:
            changeSetId: "chgSet"
            eTag: undefined
            error: undefined
            groupId: "create"
            ...
        type: "..."
        uri: "/sap/opu/odata/sap/..."

The changed entities have no groupId, they look like so:

UpdatedObject(Key='123'):
Attribute: "abc"
    __metadata:
        id: ".../sap/opu/odata/sap/..."
        type: "..."
        uri: ".../sap/opu/odata/sap/..."

So my only idea at the moment is to loop over the entries from "getPendingChanges" and check if there's a groupId or not. As I'm not happy with this solution I'd like to ask you if there's a smarter way to determine the groups with pending requests.

0 Answers
Related