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.
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
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 7 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 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.