Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Hello,

There are use cases where you might need to send multiple create, edit and delete request in a single batch. By default UI5 send the multiple request in a single batch with same change sets ids. So if any record fails, all the records are rolled back if changeset is not handled in backend.

With this blog I will show you, how you can send multiple CRUD operation in a single batch with different changeset ids. With different changeset ids all the records will be independent of each other.

Create a master map with following parameter
var mParameter = {

urlParameters: null,
groupId:"randomgroupid",
success: function(innerdata) {

//This success handler will only be called if batch support is enabled.
//If multiple batch groups are submitted the handlers will be called for every batch group.

},
error: function(oError) {

}
};

 

Create a map for each entry with following parameters
	var singleentry = {
groupId: "randomgroupid",
urlParameters: null,
success: function(innerdata) {

//The success callback function for each record

},
error: function(oError) {

//The error callback function for each record
};

 

For my current use case am reading a complete record from a sap.ui.table and sending it as a POST

 
//data model contains the table data
//Assign unique changeset id to singleentry
for (var i = 0; i < data.BP.length; i++) {
singleentry.properties= data.BP[i];

singleentry.changeSetId="changeset "+i;
this.getOwnerComponent().getModel().createEntry("/Entity", singleentry);
}

 

Finally submit the changes
this.getOwnerComponent().getModel().submitChanges(mParameter);

 

For more details refer : https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel/methods/createEntry

 

Thanks

Mohit Kanoria
5 Comments