Skip to Content

createBatchOperation statement failing?

Dec 14, 2017 at 09:25 PM


avatar image

Hi Everyone,

I am trying to create a batch operation, however, when I call my code I see in the debugging tools that my statement for the batch is failing?

I am following the example from this blog post:

My code:

var view = controller.getView();
var assetList = [];
var that = view.getController();
    //create an array of batch changes and save
    var batchChanges = [];
    batchChanges.push( that.oModel.createBatchOperation("SRMSHOPPING_CART", "POST", json) );
    batchChanges.push( that.oModel.createBatchOperation("SRMSHOPPING_CART", "POST", json) );

My code fails on the first call to createBatchOperation

Chrome Tools identify this error:

VM4276:132 Uncaught TypeError: Cannot read property 'createBatchOperation' of undefined at constructor.eval (eval at <anonymous> (sap-ui-core-dbg.js:613), <anonymous>:132:36) at fnClass.EventProvider.fireEvent (sap-ui-core-dbg.js:20766) at fnClass.Element.fireEvent (sap-ui-core-dbg.js:31507) at fnClass.firePress (sap-ui-core-dbg.js:21809) at (Button-dbg.js:626) at fnClass.Element._callEventHandles (sap-ui-core-dbg.js:31056) at fnClass.Element._handleEvent (sap-ui-core-dbg.js:31034) at constructor.UIArea._handleEvent (sap-ui-core-dbg.js:36721) at HTMLDivElement.proxy (sap-ui-core-dbg.js:828) at HTMLDivElement.dispatch (sap-ui-core-dbg.js:5096)

I am using SAPUI version 1.24.2


10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Keith Warnock Dec 14, 2017 at 09:46 PM

Hi All,

I was able to get it working. Follow the example for batch operations from this document from the open sap course NEXT STEPS IN SOFTWARE DEVELOPMENT ON SAP HANA

Pages 186-187

the correct code is as follows:

var batchModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/srmnxp/SRMSHOPPING_CART/", true);
var batchChanges = [];
var json2 = oModel;
for ( var k = 0; k < 2; k++ ) {

  batchChanges.push(batchModel.createBatchOperation("/SRMSHOPPING_CART", "POST", json2) );

10 |10000 characters needed characters left characters exceeded