cancel
Showing results for 
Search instead for 
Did you mean: 

POST in ODate Service

0 Kudos

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(...

  }

  });

Accepted Solutions (1)

Accepted Solutions (1)

WouterLemaire
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

former_member182862
Active Contributor
0 Kudos