Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jibin_joy
Contributor

Based on document Sample UME Application using SAPUI5 and SAP Gateway - Part II

I like to Update code for the sapui5 1.8.4

For Update

once model is set with service url .......

       var oModel = new sap.ui.model.odata.ODataModel 

                                                  ("http://gwserver.com:8000/sap/opu/odata/sap/Z_UI5_USER_MAINT_CM/");     

              sap.ui.getCore().setModel(oModel); 

use oModel update method

.update(sPath,oContext,oData,fnSuccess,fnError,bMerge);

where

* Trigger a PUT/MERGE request to the odata service that was specified in the model constructor.

* @Param {String} sPath A string containing the path to the data that should be updated.

*                                                                       The path is concatenated to the sServiceUrl which was specified

*                                                                       in the model constructor.

* @Param {Object} [oContext] If specified the sPath has to be is relative to the path given with the context.

* @Param {object} oData data of the entry that should be updated.

* @Param {function} [fnSuccess] a callback function which is called when the data has

*                                                               been successfully updated.

* @Param {function} [fnError] a callback function which is called when the request failed. The handler can have the parameter: oError which contains

* additional error information.

* @Param {Boolean} [bMerge=false] trigger a MERGE request instead of a PUT request to perform a differential update

   there is small problem in the document.

the parameter sequence mentioned in document is

   sPath,oContext,oData,fnSuccess,fnError,bMerge

but in the code it is

  sPath,oData,oContext,fnSuccess,fnError,bMerge

oModel.update('z_ui5_user_maintCollection('AGAMPA')',Odata);

________________________________________________________________________

if the XSRF token is disabled in SAP Gateway we have to pass the header X-Requested-With=XMLHttpRequest based on http://help.sap.com/saphelp_gateway20sp03/helpdata/en/e6/cae27d5e8d4996add4067280c8714e/frameset.htm

we can have add X-Requested-With in the Model

oModel.oHeaders["X-Requested-With"] = "XMLHttpRequest"

_______________________________________________________________________

Other  Operation

For Create

* Trigger a POST request to the odata service that was specified in the model constructor.

* @Param {String} sPath A string containing the path to the collection where an entry

*                                                                       should be created. The path is concatenated to the sServiceUrl

*                                                    which was specified in the model constructor.

* @Param {Object} [oContext] If specified the sPath has to be is relative to the path given with the context.

* @Param {object} oData data of the entry that should be created.

* @Param {function} [fnSuccess] a callback function which is called when the data has

*                                                               been successfully retrieved. The handler can have the

*                                       following parameters: oData and response.

* @Param {function} [fnError] a callback function which is called when the request failed. The handler can have the parameter: oError which contains

.create(sPath,oContext,oData,fnSuccess,fnError)

For Batch

http://scn.sap.com/community/developer-center/front-end/blog/2012/11/18/gateway-batch-calls-from-sap...

For Delete

* Trigger a DELETE request to the odata service that was specified in the model constructor.

* @Param {String} sPath A string containing the path to the data that should

*                                                    be removed. The path is concatenated to the sServiceUrl

*                                                    which was specified in the model constructor.

* @Param {Object} [oContext] If specified the sPath has to be is relative to the path given with the context.

* @Param {function} [fnSuccess]  a callback function which is called when the data has

*                                                               been successfully retrieved. The handler can have the

*                                       following parameters: oData and response.

* @Param {function} [fnError] a callback function which is called when the request failed. The handler can have the parameter: oError which contains

* additional error information.

.delete((sPath,oContext,fnSuccess,fnError))

Regards,

Jibin Joy

1 Comment
Labels in this area