Didn't get any data on OData

I need pass parameter in my oData.

The URL have to be like this http:// my_gateway_system:port/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/ztest_nameset('RUBENS')

Below is my code

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);

When I past the url http:// my_gateway_system:port/sap/opu/odata/sap/ZGW_TRANSF_APPROVAL_SRV_02/ztest_nameset('RUBENS') in my broswer it's work, but when I run my code it's not working

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Apr 20, 2017 at 01:07 PM
    -1

    Try to use as shown below to pass filter:

    var urlParameterValues = { "$filter": "SOME_FIELD eq '" + VALUE + "'" };

    oModel.read("/ztest_nameset('RUBENS')", {urlParameters:urlParameterValues, success: function(): error: function()})

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 20, 2017 at 01:14 PM

    you run it in eclipse? probably same origin issue.

    just deploy to abap server to run.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 21, 2017 at 07:53 AM

    You need to use urlParameters property of the read .. see this for more info on read function ..

    read(sPath, mParameters?): object Trigger a GET request to the odata service that was specified in the model constructor. The data will not be stored in the model. The requested data is returned with the response. Parameters:

    {string}sPathA string containing the path to the data which should be retrieved. The path is concatenated to the sServiceUrl which was specified in the model constructor.{map}mParameters?Optional parameter map containing any of the following properties:{object}mParameters.context?If specified the sPath has to be is relative to the path given with the context.{map}mParameters.urlParameters?A map containing the parameters that will be passed as query strings{boolean}mParameters.async?, Default: truetrue for asynchronous requests.{array}mParameters.filters?an array of sap.ui.model.Filter to be included in the request URL{array}mParameters.sorters?an array of sap.ui.model.Sorter to be included in the request URL{function}mParameters.success?a callback function which is called when the data has been successfully retrieved. The handler can have the following parameters: oData and response.{function}mParameters.error?a callback function which is called when the request failed. The handler can have the parameter: oError which contains additional error information.

    Returns:

    {object}an object which has an abort function to abort the current request.
    Add comment
    10|10000 characters needed characters exceeded

Skip to Content