cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - OData don't show any data

rubens12
Participant
0 Kudos

I make an SAPUI5 application and deploy in my abap server.

I need to acess the url http://my_gateway_system:port/sap/opu/odata/sap/ZGW_TRANSF/ztest_nameset('RUBENS') via OData.

When I copy this URL and past in my browser I get some data, but when I run my application, isn't get any data

Below is my code where I call the OData

var sServiceUrl = "http://<my_gateway_system>:<port>/sap/opu/odata/sap/ZGW_TRANSF";
    var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true, "username", "password");

    var oJsonModel = new sap.ui.model.json.JSONModel();

    oModel.read("/ztest_nameset('RUBENS')", null, null, true, function(oData, response) {
        oJsonModel.setData(oData);

    });
    sap.ui.getCore().setModel(oJsonModel);

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member340030
Contributor
0 Kudos

Hi ,

You can't access URL directly like this http://<my_gateway_system>:<port>/sap/opu/odata/sap/ZGW_TRANSF, it will give Cross origin error ..you need to use the relative paths .. if you have deployed your ui5 app in the gateway system (same where you have your service)

thanks

Viplove