Request clarification before answering.
if you don't anything at your odata service, that is how batch works,
you can change the default behavior, please read through
This handling is also called processing a changeset in defer mode.
When method CHANGESET_BEGIN is called a data provider can use the changing parameter CV_DEFER_MODE to inform the framework that it can process all changeset operations at once (deferred processing). Based on the list of entity set name, entity type name and action name, a data provider can dynamically set the exporting parameter mentioned above to inform the framework that it will process the current changeset at once or to reset this parameter to have a single processing as usual. Default implementation is single processing. That means without any changes in a data provider each changeset operation will be processed one after another as usual.
If CV_DEFER_MODE is set, the framework will call the data provider using the new method CHANGESET_PROCESS with importing parameter IT_CHANGESET_REQUEST containing a list of change set operations. Each entry of this list contains the technical request context IO_TECH_REQUEST_CONTEXT as usual but also a message container for error or information message happened during the processing. Response data of a change set operation including HTTP custom headers and ETag (if it exists) must be returned in changing parameter CT_CHANGESET_RESPONSE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
v2 model has batch enable by default, no need to createBatchOperation
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Question “IF variant found with incompatible validity period”
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you can use $batch option as recommended by ivan and it had to be supported from UI5 and oData service side.
Check the below blog on implementing batch
Service side oData Batch
UI5 implementation Gateway
Thanks,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello thanks for answer.
I trying batch operation;
var serviceUrl = "/sap/opu/odata/sap/ZBZ_QM_KALITE_SONUC_SRV/$batch";<br>var oModel = new sap.ui.model.odata.v2.ODataModel(serviceUrl);<br>var contactEntry2 = {}; <br>contactEntry2.Insplot = sInsplot;
contactEntry2.Inspchar = sInspchar;<br>oModel.setUseBatch(true); <br>var batchChanges = [];<br>batchChanges.push(oModel.createBatchOperation(sPath, "PUT", contactEntry2));
oModel.addBatchChangeOperations(batchChanges);
but i getting error ;
oModel.createBatchOperation is not a function..
Need to open a property for batch?

var oDataModel = this.getView().getModel();
var batchChanges = [];
batchChanges.push(oDataModel.createBatchOperation("FirstDataSet", "POST", contactEntry1)); batchChanges.push(oDataModel.createBatchOperation("Second Dset", "POST", contactEntry2));
oDataModel.addBatchChangeOperations(batchChanges);
oDataModel.submitBatch(function(success) { var bresponse = success.__batchResponses[0]; if (bresponse.__changeResponses) { var scres = bresponse.__changeResponses[0].data; console.log("1"); } else if (bresponse.response) { var responseBody = success.__batchResponses[0].response.body; var successObj = JSON.parse(responseBody); var message = successObj.error.message.value; console.log("2"); sap.m.MessageBox.show(message, { title: "Success", icon: sap.m.MessageBox.Icon.SUCCESS, actions: [sap.m.MessageBox.Action.OK] }); } }, function(error) { var resBody = error.response.body; var errObj = JSON.parse(resBody); var message = errObj.error.message.value; console.log("3"); sap.m.MessageBox.show(message, { title: "ERROR", icon: sap.m.MessageBox.Icon.ERROR, actions: [sap.m.MessageBox.Action.OK], details: message }); }, false);
Try as above, looks you are using spath in create bath.
see this Open SAP tutorial for more info on batch operations:
https://open.sap.com/courses/hana2/items/42yDjpxcjSPSzz4JFCvA3H
Hi Burak,
You should use $batch operations in order to send multiple items to the same OData service. Your service must provide support for batch operations. Check this blog for UI5 details on how to implement this.
Regards,
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Burak,
Deep entity will post a nested structure (i.e: header and line items) in a single run. It also reduces the number of Odata calls, but it implies you are using an Odata with $expand feature. If this is your case, than you should be using NW Gateway as you OData provider to be able to implement this feature.
Batch operations will send multiple Odata operations on a single run. Suppose your app has a hierarchy table grouped by header an line items at the 2nd level of each header. You edit some of the line items on multiple headers and now you need to send them to your Odata service in a single run to update the table. You could call the OData service multiple times (one for each header) using the deep entity creation, but you want to do it in a single run. That's where the $batch request will aid you. You could send multiple deep entity calls on a single batch request.
Regards,
Ivan
Hi ivan.mirisola again,
I have a question for about batch operation.
Example;
I have a table with 10 row. I am using batch operation and each one goest to createSet.(10 row.)
Bapi works for every line.(It actually needs to work once for all lines.)
Because I have to take the result of each line and process according to the result.(commit , rollback..)
I can't do because batch data is sent one by one.Can you please help me ?
Is this what you are looking for?
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.