Skip to Content
0
Apr 15, 2014 at 05:31 AM

Error in CRUD application calling from an UI

46 Views

Hi Everyone,

I am trying to implement the code to call the CRUD application from an UI from the below blog,

Building a CRUD Application with SAPUI5 Using Odata Model But I am facing some issues.

Following I am giving the code where I got stuck. When I am pressing the create button the dialog is opening but during fetching and getting the request it is showing the alert of the 1st err function which I have made bold. But why the code is going there I am not able to uderstand.Please help.

Code:

OData.request

({

requestUri: "http://server:host/sap/opu/odata/sap/ZGW638785_EMPLOYEE_TEST_SRV/EmployeeCollection/",

method: "GET",

headers: {

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

"Content-Type": "application/atom+xml",

"DataServiceVersion": "2.0",

"X-CSRF-Token":"Fetch" }

},

function (data, response)

{

alert("1st func "+mandt_var+" "+employeeID_var +" "+ address_var+" " + datejoining_var + " " + yearexp_var);

header_xcsrf_token = response.headers['X-CSRF-TOKEN'];

OData.request

({

requestUri: "http://server:host/sap/opu/odata/sap/ZGW638785_EMPLOYEE_TEST_SRV/",

method: "POST",

headers: {

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

"Content-Type": "application/atom+xml",

"DataServiceVersion": "2.0",

"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",

"X-CSRF-Token": header_xcsrf_token

},

data:

{

mandt: mandt_var,

employeeID:employeeID_var,

address:address_var,

dateOfJoining: datejoining_var,

yearOfExp: yearexp_var,

}

},

function (data, response)

{

alert("2nd Func "+mandt_var+" "+employeeID_var+" "+address_var+" "

+ datejoining_var+" "+yearexp_var);

document.location.reload(true);

$("<div>Returned data " + window.JSON.stringify(data) + "</div>").appendTo($("#MessageDiv"));

},

function (err)

{

alert("1st err func "+mandt_var+" "+employeeID_var+" "+address_var+" "

+ datejoining_var+" "+yearexp_var);

$("<div>Returned error " + window.JSON.stringify(err.response) + "</div>").appendTo($("#MessageDiv"));

}

);

},

function (err)

{

alert("2nd err func "+mandt_var+" "+employeeID_var+" "+address_var+" "

+ datejoining_var+" "+yearexp_var);

var request = err.request; // the request that was sent.

var response = err.response; // the response that was received.

alert("Error in Get -- Request "+request+" Response "+response);

}

);

And also I am getting the below error message from the browser,

Please help in this matter.

Regards,

Soumya

Attachments

Capture.JPG (60.3 kB)