Dear vijay,
For single data posting i am doing like this.Its working fine.Likewise how to fetch reed URL and post write URL in order to create deep insert.
OData.request
({
requestUri: "http://dnmecq.danamconsulting.com:8000/sap/opu/odata/sap/ZPO_CREATE_SRV/PomaterialSet('000000000000001157')?$format=xml",
method: "GET",
user: "XXX",
password: "YYYY",
headers:
{
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token":"Fetch" }
},
function (data, response)
{
header_xcsrf_token = response.headers['x-csrf-token'];
OData.request
({
requestUri:
"http://dnmecq.danamconsulting.com:8000/sap/opu/odata/sap/ZPO_CREATE_SRV/PomaterialSet",
method: "POST",
user: "XXX",
password: "yyyy",
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:
{
PoItem : PoItem ,
Material: Material,
Quantity : Quantity,
PoUnit: PoUnit,
Plant : Plant,
PurchOrg : PurchOrg,
PurGroup : PurGroup,
SPlant : SPlant
}
},
function (data, response)
{
jQuery.sap.require('sap.m.MessageToast');
sap.m.MessageToast.show("Purchase Order Created successfully",{duration:10000,
width: "15em", // default
my: "center top", // default
at: "center top", // default
of: window, // default
offset: "0 0", // default
collision: "fit fit", // default
onClose: null, // default
autoClose: true, // default
animationTimingFunction: "ease", // default
animationDuration: 1000, // default
closeOnBrowserNavigation: true // default
});
//document.location.reload(true);
// $("<div>Returned data " + window.JSON.stringify(data) + "</div>").appendTo($("#MessageDiv"));
},
function (err)
{
$("<div>Returned error " + window.JSON.stringify(err.response) + "</div>").appendTo($("#MessageDiv"));
}
);
},
function (err)
{
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);
}
Please help me on this.