Skip to Content

OData create, update - not working

Hi All,

I have been trying create, update operations with the following code.

Please check and suggest me if I need to change anything as it is giving following error..

Code:

var url = "xsodata file url";

var oModel = new sap.ui.model.odata.ODataModel(url, true);

var content = {

"content-type": "application/json;charset=utf-8"

};

oModel .setHeaders(content);

var oEntry = {};


oEntry.OBJECT_TYPE = val1;

oEntry.VALUE = val2;

oEntry.TYPE = val3;

oModel .refresh();

oModel .create("/entityName", oEntry, null, function() {

sap.m.MessageToast.show("Update successful!!!");

}, function() {

alert("Update failed")

}, true);

and for update,

oModel .update("/entityName('key value')", oEntry, null, function() {

sap.m.MessageToast.show("Update successful!!!");

}, function() {

alert("Update failed")

}, true);

Thanks,

Surendra.

Capture.PNG (27.3 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Apr 26, 2016 at 07:35 AM

    Hi Surendra,

    Current OData functionality in ByD only allows reading of report data. Create/Update are not supported.

    From what I have heard, there is a plan to provide a new (different) OData interface on the ByD business objects that will allow Create/Update operations, but there is no committed release date or version for this.

    Regards,

    Eelco

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 26, 2016 at 12:17 PM

    if you are using HANA, an alternative would be to post your object to an XSJS service and then run a stored procedure.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.