cancel
Showing results for 
Search instead for 
Did you mean: 

deleted question

01-02-2018 11:37 AM
2891 views 13 comments
0 Likes
SAP Managed Tags
Subscribe

deleted question

0 Likes

Accepted Solutions (0)

Answers (5)

Answers (5)

junwu
SAP Champion
SAP Champion
0 Likes

if you don't anything at your odata service, that is how batch works,

you can change the default behavior, please read through

https://help.sap.com/saphelp_gateway20sp12/helpdata/en/90/dc8363306c47d3b2fca1398f5de94b/frameset.ht...

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.

junwu
SAP Champion
SAP Champion
0 Likes

v2 model has batch enable by default, no need to createBatchOperation

Former Member
0 Likes

Question “IF variant found with incompatible validity period”

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.

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

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

former_member489109
Participant
0 Likes

Thanks for answer.

What is the difference between batch and deep entity?

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

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

junwu
SAP Champion
SAP Champion
0 Likes

batch: send multiple requests(each one contains a record) in one shot

deep entity: one request is sent, which contains multiple records

former_member489109
Participant
0 Likes

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 ?

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Likes

Is this what you are looking for?