cancel
Showing results for 
Search instead for 
Did you mean: 

Passing input to a oData service

Former Member
0 Kudos

Hi,

    I am trying to develop a simple mobile application using sapui5. In this application I have 2 sap.m.Input fields to enter two numbers.

These two numbers are then passed to oData service,this odata service intern perfoms calculations over those two inputs for e.g., addition

and returns the result back to the app.

My controller code is as follows:

calcu:function(n1C,n2C){

          var oModel=new sap.ui.model.odata.ODataModel("proxy/sap/opu/odata/sap/ZMY_EXPERIMENT_SRV",false,"uname","password");

              oModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

                    sap.ui.getCore().setModel(oModel);

          n1C.bindProperty("value","/A");

          n2C.bindProperty("value","/B");

          oModel.attachRejectChange(this,function(oEvent){

              alert("You are already editing another Entry! Please submit or reject your pending changes!");

          });

          oModel.submitChanges(function(){alert("successfull");},function(){alert("not successfull");});

          alert(oModel.getProperty("/A"));

   alert(oModel.getProperty("/B"));

          alert(oModel.getProperty("/Res"));

          }

n1C,n2C are Input fields,and "/A" ,"/B" ,"/Res" are properties. On click of a "addition" button "calcu" function is called.

As Binding mode is set to "TwoWay",the changes made in textfield should update in a model .

But on execution of the app it is showing "undefined" in alert box.

There is no error in google chrome's developers tool and able to see XHR file.

Could you please let me know where i am going wrong.

Thank you,

Vijay.

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos