Skip to Content
0

sapui5 multi crud operations?

Jan 02 at 10:37 AM

239

avatar image

Hi experts,

I'm sending line by line.It's working np. but now I want multi CRUD operations.

I have a record button.I want to send all lines.

deepent.png (44.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Ivan Mirisola
Jan 02 at 10:27 PM
0

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

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Thanks for answer.

What is the difference between batch and deep entity?

0

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

0
Burak Özçetin

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

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

0

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 ?

0

Is this what you are looking for?

0
Mahesh Chandra VVNS Jan 04 at 01:34 PM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

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?

1212.jpg (24.7 kB)
0
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 
0
Mahesh Chandra VVNS

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

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

0
avatar image
Former Member Jan 05 at 11:54 AM
0

Question “IF variant found with incompatible validity period”

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Jan 06 at 06:43 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Jan 06 at 06:52 PM
0

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.htm

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.

Share
10 |10000 characters needed characters left characters exceeded