on 05-11-2020 9:16 AM
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
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
}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.