Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue while consuming SAP Demo gateway Service ( Services hosted in https://sapes4.sapdevcenter.com )

Hello UI5 Gurus,

I am practicing  different SAP UI5 controls by creating sample UI5 apps.

Till now I have been using http://services.odata.org/V4/Northwind/Northwind.svc/

in

?$format=json

Therefore, directly getting json data and thereby using sap.ui.model.json.JSONModel() for setting model to UI Controls.

Now am trying to  consume data from SAP Demo Gateway services using sap.ui.model.odata.ODataModel


But not able to , can anyone please highlight where I am making the mistake.

JS Bin - Collaborative JavaScript Debugging

Note: In the code I have put the password ( just replaced with ****** for the sake of posting it publicly ).

Thanks,

Sijin

replied

Am sharing the solution for beginners like me :

<!DOCTYPE html>

<html>

<head>

  <script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap"    

  data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.ui.commons,sap.ui.table"></script>

  <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>

  <script>

 

     var service_url = "https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/";

     var oModel = new sap.ui.model.odata.ODataModel(service_url,true,"P1128538","**********");

        

  var oTable = new sap.ui.table.Table({ // create Table UI

  columns : [

   {label: "Carrier ID", template: "carrid"},  

   {label: "Connection ID", template: "connid"},

   {label: "Flight Time", template: "fldate"},  

  ]

  });

    

  oTable.setModel(oModel);

  oTable.bindRows("/FlightCollection");

  oTable.placeAt("content");

  </script>

</head>

<body class="sapUiBody">

    <div id="content"></div>

</body>

</html>

Note : The above may not work in some browsers like Firefox due to CORS issue. In that case try with other browsers like I.E or Safari.

And in the below section ,

var oModel = new sap.ui.model.odata.ODataModel(service_url,true,"P1128538","**********");

please replace ******* with your password for accessing SAP's ES4 system.

Thanks,

Sijin

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question