on ‎2017 Feb 22 11:24 AM
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.
Request clarification before answering.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check this link and scroll down to "Batch Processing"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Radek,
Thanks for your help.
I am using oDataModel.v2 api:
I followed the same link and tried it--> not working(still single batch call for two subsequent oDataModel.read calls).
in this link https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/6c47b2b39db9404582994070ec3d57a2.html There is one code line:
oModel.submitChanges({groupId:"myGroupId", success: mySuccessHandler, error: myErrorHandler});There is a success call function in the above statement, i think i should give success call back function in the oDataModel.read call, not here right ?
BR,
Venky.
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.
Hi Venkatesha
I believe you can set the batch group ID there so that it belongs to the same group and requested together.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this is the example of setting a group ID. I believe without setting the groupId for the request, SAPUI5 will generate a unique ID for each request so they will never inside the same batch. Take a look at the oDataModel.v2 api will help you I guess
var sGroupId = ...; //you can put anything you want, I myself use a timestamp.
oDataModel.setChangeGroups({
"/record": { groupId: sGroupId }
});
oDataModel.setDeferredGroups([sGroupId]); //deferred the group
oDataModel.update("/record",data,{groupId : sGroupId}); //make sure to put the group in the request.
oDataModel.submitChanges({groupId: sGroupId});
Hi Hans,
I am using oDataModel.v2 api:
capture.png --> is the screenshot from manifest.json
What am i doing is:
oDataModel = that.getOwnerComponent().getModel();
aFiltersOData = that._createODataFilters("Entity1");
oDataModel.read("/Entity1", {
filters: aFiltersOData,
success: that._oDataReadBaseSuccessHandler
});
I tried your suggestion like this:
oDataModel = that.getOwnerComponent().getModel();
aFiltersOData = that._createODataFilters("Entity1");
var sGroupId = "Group1";
oDataModel.setChangeGroups({
"/Entity1": { groupId: sGroupId }
});
oDataModel.setDeferredGroups([sGroupId]); //deferred the group
oDataModel.update("/Entity1",{groupId : sGroupId}); //make sure to put the group in the request.
oDataModel.submitChanges({groupId: sGroupId});
oDataModel.read("/Entity1", {
filters: aFiltersOData,
success: that._oDataReadBaseSuccessHandler
});
it did not work(still single batch call for two subsequent oDataModel.read calls)
in your code snippet, there is a one 'data', i left it blank, is this causing any problem ?
oDataModel.update("/record",data,{groupId : sGroupId});BR,
Venky.
my code snippet is an example of batch request for update. you need to specify the group id for your read as well, and you need to use the submitChanges the success will trigger once all the request in the batch are processed successfully or you can attach batchRequestCompleted on your read function.
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
Use sap.ui.model.odata.v2.ODataModel instead. It takes care of batch calls itself.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.