Skip to Content

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

Data is not showing up in SAPUI5 Table

Hi,

I followed this (http://scn.sap.com/community/developer-center/front-end/blog/2012/06/01/sample-application-using-ui5-and-gateway) guide to create an SAPUI5 app getting data from the ECC server. We have gateway installed in our ECC system.

I am able to successfully test the Query and Read operation using the RESTClient tool in firefox. If I enter the URL for the Query operation (http://ecchost:8000/sap/opu/odata/sap/Z_USER_RFC_RIS/z_user_rfc_risCollection) in the browser, it asks for the username and password. Once I enter correct username and password, I can get the response in XML.

But in SAPUI5 table I am getting No Data. I am testing it using my local Tomcat server.

Here is the code I am using:

<!DOCTYPE html>
<html><head>
    <meta http-equiv='X-UA-Compatible' content='IE=edge' />
    <title>User Search</title>
    <script id='sap-ui-bootstrap' type='text/javascript'
        src='./resources/sap-ui-core.js'
        data-sap-ui-theme="sap_goldreflection"
        data-sap-ui-libs='sap.ui.commons,sap.ui.ux3,sap.ui.table'></script>
    <script type="text/javascript">
    
      var oModel = new sap.ui.model.odata.ODataModel("http://ecchost:8000/sap/opu/odata/sap/Z_USER_RFC_RIS/", false, "rishi", "xxxx1234");
      sap.ui.getCore().setModel(oModel);

      var userDetailsTable = new sap.ui.table.DataTable({
     title : "Available Users",
     width : "75%",
     visibleRowCount : 5,
     ExpandedVisibleRowCount : 20,
     selectionMode : sap.ui.table.SelectionMode.Single,
     editable : false
    });
   
      //Add all columns
      userDetailsTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "User ID"}),
        template: new sap.ui.commons.TextField().bindProperty("value", "username"),
        sortProperty: "username" }));
              
      userDetailsTable.addColumn(new sap.ui.table.Column({
         label: new sap.ui.commons.Label({text: "First Name"}),
         template: new sap.ui.commons.TextField().bindProperty("value", "firstname"),
         sortProperty: "firstname" }));
      userDetailsTable.addColumn(new sap.ui.table.Column({
         label: new sap.ui.commons.Label({text: "Last Name"}),
         template: new sap.ui.commons.TextField().bindProperty("value", "lastname"),
         sortProperty: "lastname" }));  
     
      userDetailsTable.bindRows("z_user_rfc_risCollection"); //Bind the operation to main table rows, so it calls Query operation and binds the data to table.
      var userDetailsTableLayout = new sap.ui.commons.layout.MatrixLayout();
      userDetailsTableLayout.createRow( userDetailsTable);    
      userDetailsTableLayout.placeAt("UserDetailsTable");  
    
     

-->
</script>
</head>
<body class="sapUiBody" role="application">
<div id="appBody"  class="wrapper"></div>
<div id="UserDetailsTable"  class="wrapper"></div>
<div id="UserTabs" class="wrapper"></div>
<p></p>
</body>
</html></html>

Please let me know what I am missing here.

Thanks,

Rishi

Former Member
Not what you were looking for? View more on this topic or Ask a question