Skip to Content
0

SAPUI5: Problems with ODATA

Sep 06, 2017 at 06:42 AM

79

avatar image

Hey,

I have a problem with a the following function:

var oModel = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/Z_LIC_SRV/");
var entitySet = "/systemDataSet?search=" + sysName;
oModel.read(entitySet, {
	method: "GET",
	success: function(data) {
		console.log(data);
		that.createModel(data);
	}
});

Some days ago the function works, but now the response is an empty object. If I use the same ODATA-Service, but another entitySet without the search parameter it works well too.

Does someone have an idea, what the problem is and what I can do to get the data?
Before someone is asking, if I call the ODATA-Service directly (with the search parameter) the response includes about 30 elements...

Thanks in advance!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Joseph BERTHE Sep 06, 2017 at 08:36 PM
1

If I were you i will do that :

var sKey = oModel.createKey("/systemDataSet");


// The method is obvious because the Read operation is always GET
oModel.read(sKey, {
     urlParameters: {
        "search": sysName
         },

    success: function(oEvent){
      // Do what you want
     }
});
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you very much :)

0
Sharath M G Sep 06, 2017 at 07:27 AM
0

When, you are invoking it through code with the filters assigned, did you confirm if the service is getting invoked - by setting an external breakpoint in service class or through breakpoint in the browser JS source code?

Also, add a function inside the oData call for error :

oModel.read(entitySet, {
	method: "GET",
	success: function(data) {
		console.log(data);
		that.createModel(data);
	},
        error: function(){
        }
});
Show 3 Share
10 |10000 characters needed characters left characters exceeded

I'm not sure if I understand it correct. By using another entitySet the code works and a direct call of the URI works well too. Additionaly the console.log method shows the empty object in the browsers console
Or do you mean it differently?

0

Hi Tim,

What I meant is: If you have set a breakpoint in the JS code in browser of the oData class in backend, is the service being invoked? If yes, you can check if filters are having value or if any error is getting generated.

I wanted you to add the additional error function within the oData call to capture the error data.

Regards.

0

The error function doesn't provide any further information.

And I set a breakpoint in the line of "oModel.read", but there I can't find the URI Parameter nor the value. Maybe I look into the wrong parameters of the structure, but I check all "matching" parameters

Is it wrong how I attach the parameter?

0