Skip to Content
0
Jun 17, 2016 at 06:36 PM

Issue with GWSAMPLE_BASIC/Business Partner Service

115 Views

Hello

I am trying to implement POST operation with GWSAMPLE_BASIC and Business Partner Entity Set. Here is my code:

Init Method:

self=this;

var surl = "proxy/http/sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/";

var omodel = new sap.ui.model.odata.v2.ODataModel(surl,true);

omodel.setDefaultBindingMode("TwoWay");

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

onPress: function()

{

var bpId = this.getView().byId("i1").getValue();

var cname = this.getView().byId("i2").getValue();

var tbl = self.getView().byId("idbp");

var x =

{

"BusinessPartnerID": bpId,

"CompanyName": cname,

"EmailAddress":"abc@yahoo.com",

"WebAddress":"http://www.google.com",

"PhoneNumber":"+111111",

"FaxNumber":"+111111",

"LegalForm":"AG",

"CurrencyCode":"USD",

"BusinessPartnerRole":"01",

"Address": {

"City":"Chicago",

"PostalCode":"60004",

"Building":"47",

"Street":"Rand Road",

"Country":"US",

"AddressType":"02",

},

} ;

var url = "proxy/http/sapes4.sapdevcenter.com/sap/opu/odata/IWBEP/GWSAMPLE_BASIC/";

var method= "POST";

var requestObj = {

requestUri: '',

method: '',

headers: {

"X-Requested-With": "XMLHttpRequest",

"Content-Type": "application/json",

"DataServiceVersion": "2.0",

"MaxDataServiceVersion": "2.0",

"Accept": "application/json"

} };

requestObj.requestUri = url;

requestObj.method = method;

requestObj.data = x;

OData.request(requestObj, function() {

alert("Success");

});

},