Skip to Content

Create entity using Batch Request in sapui5

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Aug 26, 2015 at 02:29 PM

    your code is ok, do you see a request in Dev tools / Network?

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Vikash,

      Ok, that must have been your other message where you explained - I wasn't sure which came first. My example was a bit different as I tried to explain however because I was bundling all of the separate transactions into one LUW on the back end - hence all of the extra code within the methods. Glad that it is working for you now 😊

      Regards,

      Ryan Crosby

  • Posted on Aug 27, 2015 at 11:13 AM

    Hi All,

    Got the Solution for the Batch Creation. We have to write the following code in

    /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_BEGIN :

    method /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_BEGIN.

    EXIT.

    endmethod.


    and in /IWBEP/IF_MGW_CORE_SRV_RUNTIME~CHANGESET_END


    METHOD /iwbep/if_mgw_core_srv_runtime~changeset_end.

    COMMIT WORK.

    ENDMETHOD.


    Thanks for the inputs and help.


    Regards,

    Vikash

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.