Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

POST in ODate Service

Hi all,

I have a simple form with input fields. The values of these fields I want to post via odata service into my backend by clicking a button. It´s my first post function and I don´t know how to use "oDataModel.createEntry" function (is this the right one?). Can anybody help my?

Here is my code:

var oButton = new sap.m.Button({

  text: "Post",

  press: function(){

  var postURL = "/sap/opu/odata/bao/sc_api_ldr_srv/";

  var oDataModel = new sap.ui.model.odata.ODataModel(postURL, true);

  var newData = {

  "odata.type": "/BAO/SC_API_LDR_SRV.LDR",

  "ProcessID": sap.ui.getCore().byId("ProcessID").getValue(),

    "IBAN": sap.ui.getCore().byId("IBAN").getValue(),

    "CustomerName": sap.ui.getCore().byId("CustomerName").getValue(),

    "AccountHolderName": sap.ui.getCore().byId("AccountHolderName").getValue(),

  "CustomerID": sap.ui.getCore().byId("CustomerID").getValue(),

    "LoanContractID": sap.ui.getCore().byId("LoanContractID").getValue(),

    "DisbursementCurrency": sap.ui.getCore().byId("DisbursementCurrency").getValue(),

    "DisbursementValue": sap.ui.getCore().byId("DisbursementValue").getValue()

  };

  oDataModel.createEntry(...

  }

  });

Tags:
replied

Hi Matthias,

You could use it like this:

var onSuccess = function(){myAnimationIndicator.stop();};

var onError = function(){myAnimationIndicator.stop();};


var reqHeaders = {

                    context: this,// mention the context you want

                    success: onSuccess, // success call back method

                    error: onError, // error call back method

                    async: true // flage for async true

                };

// show the loader here

myAnimationIndicator.start();

oODModel = new sap.ui.model.odata.ODataModel(myUrl);

oEntry = myNewDataEntry;

oODModel.create('myDataSet',oEntry, reqHeaders );

Also check this thread: SAPUI5: How to make an asynchronous OData .crea... | SCN

Kind regards,

Wouter

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question