Skip to Content

SAPUI5: Problems with ODATA

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Sep 06, 2017 at 08:36 PM

    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
         }
    });
    Add comment
    10|10000 characters needed characters exceeded

  • Sep 06, 2017 at 07:27 AM

    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(){
            }
    });
    Add comment
    10|10000 characters needed characters exceeded

    • 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?