on 01-05-2016 5:09 AM
Hi All,
I am not able to read value from odata,
but i can see an json alert..
I tried this way,,,oData.Type and oData.results[0].Type
Console throws an error " Type Property not found"
Regards,
Lalitha
Hi Lalitha,
Did you include library to your code in order to read Odata from sap gateway?
With Regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please find the code below::
var postdata1 = {
Reason : d1,
StartDate:dateformat,
StartTime:time1,
EndDate:dateformatend,
EndTime:time2,
Destination:d6,
AdvanceAmount:d7,
CostCenter:"",
EmpNum:empnum,
Country:"",
Currency:"",
Remark:"",
CreateTripI:[{
Receiptno:"",
ExpType: d10,
RecAmount: d12,
RecCurr: d13,
RecDate: d11format,
Shorttext: ""
},
var url3 ="/sap/opu/odata/sap/ZHCP_EXPENSE_REPORT_SRV/CreateTripHSet";
var oModel3 = new sap.ui.model.odata.ODataModel(url3, false,usr,pwd);
oModel3.refreshSecurityToken();
oModel3.setHeaders({
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token":"Fetch"
});
var token3="";
oModel3.read('',null,null,true,function(oData, oResponse) {
token3 = oResponse.headers['x-csrf-token'];
});
oModel3.setHeaders({
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"X-CSRF-Token": token3
});
oModel3.create('', postdata1, null, function(oData, oResponse){
alert(JSON.stringify(oData));
var typew = oData.Message;
alert(typew);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lalitha,
Try handling the Headers and CSRF token using ODataModel, so that you don't want to set the Headers Explicitly.
ODataModel class will handle those internally. Check the API link below for possible parameters to be passed.
Check the below code for creating a OData model and calling create with payload.
var sURL = "/sap/opu/odata/sap/ZHCP_EXPENSE_REPORT_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sURL);
oModel.create("/CreateTripHSet", postdata1, null,
function(oResponse)
{
alert(oResponse.Message);
},
function(error)
{
alert("Error");
});
Check this link for Create method in OData.
Regards
Naveenraj
Hi,
Hi,
can you please share your code?
Regards,
Kuldeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The way you are referring to JSON structure might be wrong.
Can you share your OData resonse.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.