cancel
Showing results for 
Search instead for 
Did you mean: 

oData.read function do not enter success or error function

kiefer500a
Explorer
0 Kudos

Hi there,

I am trying to do an oData.read where in success function I am creating a JSON-Model from oData, but its not entering success or error function. Can someone tell me what I am doing wrong? Here my Code:

var sServiceUrl = "/sap/opu/odata/sap/ZPP_ODATA_UMLAGERUNG_SRV/";
var oModel = new sap.ui.model.odata.v2.ODataModel( sServiceUrl , {});
sap.ui.getCore().setModel(oModel);
var oFilter = new Array();
var input = mResult.text;
oFilter[0] = new sap.ui.model.Filter({
                path: "Lenum",
                operator: sap.ui.model.FilterOperator.EQ,
                value1: input
            });  

sap.ui.getCore().getModel().read("/LEINSet", null, null, oFilter, function(oData, response){
            // create JSON model
              var oODataJSONModel =  new sap.ui.model.json.JSONModel();
               
              // set the odata JSON as data of JSON model
              oODataJSONModel.setData(oData);
              
              sap.ui.getCore().setModel(oODataJSONModel, "localModel");
            
        }, function(oError){
        alert("Reading failed: " + oError);
        });

Thanks and best regards.

Jay

former_member540067
Active Participant
0 Kudos

Did you checked on network tab whats the response and you tried putting the breakpoint?

Accepted Solutions (1)

Accepted Solutions (1)

pfefferf
Active Contributor
0 Kudos

The read function of the odata model has only two parameters. The first one is the path and the second one is an options object. So you have to called it like following:

.read("/LEINSet", {
  success: function(oData, response) {
    // your logic
  },
  error: function(oError) {
    // your logic
  }
});

Answers (1)

Answers (1)

former_member667434
Active Participant
0 Kudos

Hi kiefer500a,

OModel.read supports both Success and error function.

Please check console, if there is any error and also check your network if the call is happening properly and is returning results.

oModel.read("/YourEntitySet", {
success: function (oData, response) { 
//your logic
}, rrror : function  (oData, response) {
//your logic
}
}