Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

Create entity using Batch Request in sapui5

$
0
0

Hello Experts,

 

I need one help regarding batch processing.

 

I have to create two entries using the button Create in one call which i am trying with the help of Batch OData calls.

 

I have implemented by create method of the DPC_EXT Class. Now once the call happens from the frontend, how the backend will get called means which method and what kind of code we have to write to handle the batch call.

 

Please find out the call which i am doing from the UI :

 

var oButton = new sap.ui.commons.Button({

  id : 'B-Create',

  text : 'Batch Call',

  width : '10em',

  press : function(){

 

  userEntry1 = { 

  Bname : 'Ned', 

  Address : 'Flanders', 

  City : 'Raipur', 

  State: 'Chatisgarh', 

       }, 

       userEntry2 = { 

  Bname : 'Chief', 

         Address : 'Wiggum', 

         City : 'Delhi', 

         State: 'Delhi', 

       }; 

     //create an array of batch changes and save 

     var batchChanges = []; 

     batchChanges.push(oModel.createBatchOperation("userdetails", "POST", contactEntry1) ); 

     batchChanges.push(oModel.createBatchOperation("userdetails", "POST", contactEntry2) ); 

     oModel.addBatchChangeOperations(batchChanges); 

     //submit changes and refresh the table and display message 

     oModel.submitBatch(function(data) { 

      

function(err) { 

       alert("Success "); 

     }

     }, function(err) { 

       alert("Error occurred "); 

     }); 

   }, 

 

Note : userdetails is my entity set name , and the create method of DPC_EXT Class has already being redefined and working perfectly.

 

Kindly help me the steps and the codes which i have to write.

 

Best Regards,

Vikash


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>