Skip to Content

how to initiate multiple batch requests, any sample code ?

Hi,

I am making two calls of sap.ui.model.odata.read method one after the other with different entitiy sets.

Since UI5 has inbuilt capability to send both GET operations in a single batch request, i can see only one $batch request in console.

When i checked this $batch call under 'Network' tab in chrome console, i saw there are two GET commands one after the other under 'Request Payload' and this whole $batch request is taking 3 seconds.

Whereas each of these read calls spearately takes 1.5 seconds.

-->So, i think when i make two read calls one after the other, browser is actually calling them sequentially.

What i want to achieve is to make two $batch requests for odata.read calls, which are written one after the other.

Is it possible with some settings or any sample code ?

BR,
Venky.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Feb 22, 2017 at 05:47 PM

    Hello Venky,

    Try using ODataModel.setUseBatch(false);

    If you want to have 2 different requests then try disabling the request as above and see whether it serves your purpose.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 22, 2017 at 12:05 PM

    Use sap.ui.model.odata.v2.ODataModel instead. It takes care of batch calls itself.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 22, 2017 at 12:20 PM

    Hi Venkatesha

    I believe you can set the batch group ID there so that it belongs to the same group and requested together.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Hans,

      Thanks for the solution i implemented the same with below code

      var sGroupId = "myId";

      oODataModel.setChangeGroups({ "/C_Proc": { groupId: sGroupId } });

      oODataModel.setDeferredGroups([sGroupId]); //deferred the group

      oODataModel.read("/C_Proc",{

      filters: aFiltersOData,

      groupId : sGroupId,

      urlParameters: { $select: parameters" },

      success: that._oDataRead });

      oODataModel.submitChanges({groupId: sGroupId});

      Now my batch calls are different. But now i am getting error in other calls

      How can i make it false in future, I want my other calls to be executed as before??

      Thanks,

      Lavanya

  • avatar image
    Former Member
    Feb 23, 2017 at 09:03 AM

    Check this link and scroll down to "Batch Processing"

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Venkatesha N

      In oModel.read the success callback will trigger each time for a successfully read entry even if it is batch processing. You can either use submitChanges then success will trigger once per processed batch or use oModel.read and attach event batchRequestCompleted which will trigger once per batch.

  • avatar image
    Former Member
    Jan 09 at 09:06 AM

    You can assign a groupID to the particular enitytype, which you want to load later.
    Then you can call 2 submitchanges, 2nd one in the success of the first.

    Add comment
    10|10000 characters needed characters exceeded