Skip to Content
0

Binding $batch in sap UI5

Apr 28, 2017 at 07:16 AM

146

avatar image
I was trying to call a $batch operation from my application and it should be during the initial load.so i put the batch operation inside the Component itself but the batch is not getting trigger in the network. and how to bind different entityset with different controls once batch is called. i know how to bind them in normal.

	oModel.setUseBatch(true);
			var batchChanges = [];
			batchChanges.push(this.oModel.createBatchOperation("/BusinessPartnerSet" , "GET"));
			batchChanges.push(this.oModel.createBatchOperation("/ProductSet" , "GET"));
			batchChanges.push(this.oModel.createBatchOperation("/SalesOrderSet" , "GET"));
			
			
			oModel.addBatchReadOperations(batchChanges);
this.oModel.submitBatch();
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Srikanth KV Apr 28, 2017 at 04:18 PM
1

why are you not using V2 model ??, in V2 model system automatically takes care of batch

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

Hi Srikanth,

can you please ellabourate your answer. It will be very helpful for me.

Thanks.

0

Seems like you are using sap.ui.model.odata.ODataModel which is very old way of instantiation......new approach is to use V2 model(OData Version 2 Model) sap.ui.model.odata.v2.ODataModel

Also check Walkthrough tutorial

1

Hi Srikanth,

yes you are right, i changed my model to V2 API and i refered Demo Kit already. in Demo Kit they are making a Group and then sending the batch request. but i need to trigger the batch request during the initialization of app itself.

0

If binding is done in XML view then batch operation is triggered automatically when the view is instantiated.

Another option is like a AJAX call using the method read where you have the control to send the request(Note: in this case you need to set the data to model manually)

0
Sakthivel Elango
May 01, 2017 at 06:47 PM
0

There are 2 references to your model as per the code that you've posted here.

1. oModel and 2. this.oModel.

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

Hi Sakthivel,

there is just one oModel object which i have created in my program and i am just calling the oModel object with this keyword. Please advice if i am commeting any mistake. my intension is to trigger batch operation during the intial launch of the app, is this feasable and my next doubt is how i will separate different entityset once i get it in a batch .

Thanks in advance.

0