Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

SAP Netweaver Gateway CRUD Operation using SAPUI 5

$
0
0

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-sapui5

 

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


Viewing all articles
Browse latest Browse all 789

Trending Articles



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