on 07-30-2013 7:05 AM
Hi,
I am doing CRUD operations in SAPUI5 using Gateway service. In that I have to send data through Json for deep insert.I can create using Rest Client in firefox. But in my program I have to send the same data from Form. But I am in confusion how to send the data through Json for deep Insert.
Could you please send me a useful links regarding this .
Thanks&Regards
Sridevi
In SAP Gateway OData, the deep insert is the opposite of the reading a joined entityset ($expand).
For this, there must be an association between the two entitysets.
So by reading the dataset in json format with for example the path
{
path: "/Products",
parameters: {expand: "Category"}
}
Will return you the right structure. And this structure, you can use in the create.
You also must be aware that you define the model for JSON format:
sap.ui.model.odata.ODataModel(sServiceUrl, bJSON?, sUser?, sPassword?, mHeaders?, bTokenHandling?, bWithCredentials?, bLoadMetadataAsync?, annotationURI?, loadAnnotationsJoined?)
- bJSON must be true or set the header to accept JSON
And you need a CSRF token, before calling the create method.
You can implement the refreshSecurityToken method of OData model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is a simple example of the JSON format that is required...
var sId = Math.random().toString(36).substring(7);
var nCount = 1;
var oData = {
NotificationNumber : sId,
NotificationItem : [ {
ItemNumber : (nCount++).toString(),
NotificationNumber : sId,
}, {
ItemNumber : (nCount++).toString(),
NotificationNumber : sId,
}, {
ItemNumber : (nCount++).toString(),
NotificationNumber : sId,
}, ],
};
var fnSuccess = function(oData, oResponse) {
alert("Success....");
};
var fnError = function(oError) {
alert("Error creating \"/NotificationHeaders\" on Gateway Service.");
alert("Response was\n" + oError.response.body);
};
oDataModel.create("/NotificationHeaders", oData, null, fnSuccess, fnError);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You know that I am facing some troubles with NW Gateway about a deep insert but for one association:
This is my JSON:
{
FirstName : "Juan",
LastName : "Duran"
Spouse : {
FirstName : "Maria",
LastName : "Duque"
}
}
And I want those two objects to be inserted in a "ZPEOPLE" table. How should I do that? (NW Gateway)
A 'Person' entity type should be defined as PersonId, FirstName, LastName, SpouseId (The one-to-one relationship between two 'Person' entities)
Thank you in advance
Hi Sridevi,
Please see this link : http://scn.sap.com/community/developer-center/front-end/blog/2012/11/18/gateway-batch-calls-from-sap...
You can find, through the example of this blog, some samples data on how to "format" your json to "deep insert".
Take a look at how this blog fill the Contact_Status attribute.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridevi,
Get the data from the form and send the data to server via loadData method
Refer the below link:
Regards,
Ajain
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sridevi,
for general information on the´topic of data binding in SAPUI5 you can check here: https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/DataBinding.html. For more specifics on oData and write support: https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/ODataWrite.html.
Regards, Frank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.