cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

deleted question

0 Likes
View Entire Topic
MaheshChandra
Active Contributor
0 Likes

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

former_member489109
Participant
0 Likes

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?

MaheshChandra
Active Contributor
0 Likes
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 
former_member489109
Participant
0 Likes

"Uncaught TypeError: oDataModel.createBatchOperation is not a function"

I getting error again. I using v2model. V2model has createBatchOperation property? idk.