Skip to Content
2
Former Member
Oct 09, 2014 at 11:34 AM

Putting oData into sap.m.Table

1178 Views

Hi Guys,

sorry to bother you again, but developing SAP Fiori like Uis is really hard for me. Right now I can't get the Data from an oData Service into a simple sap.m.Table. This is how the oData Object that I get from the Service looks like:

As you can see, I have two Objects in the results Array. Each object contains Strings which I want to display in a sap.m.Table. This is my JS code for the table:

initBHeftModel : function(context) {
  // Using OData model to connect against a real service
  var VersBP = context.getObject().bp;
  var url = "proxy/http/crs.rz.sys.aok.de:8841/sap/opu/odata/sap/ZCM22_SERVICES_SRV_01/";
  var oModel = new sap.ui.model.odata.ODataModel(url, false);
  var filterArray = new Array();
  var BPFilter = new sap.ui.model.Filter("Bpartner", sap.ui.model.FilterOperator.EQ, VersBP);
  filterArray.push(BPFilter);
  var params = {
  context : null,
  urlParameters : null,
  async : false,
  filters : filterArray,
  sorters : null,
  success : function(oData, response) {
  var JSONBHeft = new sap.ui.model.json.JSONModel();
  console.log(oData);
  JSONBHeft.setData(oData);
  sap.ui.getCore().setModel(JSONBHeft, "VersBHeft");
  var bhtable = sap.ui.getCore().byId("bheftPageId").byId("BHeftTable");
  var oTemplate = new sap.m.ColumnListItem(  
   {cells: [   
           new sap.m.Text({text : "{Guid}"}),  
           new sap.m.Text({text : "{Kjahr}"}),
           new sap.m.Text({text : "{Hjahr}"})
           ]  
   });  
  bhtable.bindItems("/VersBHeft/oData/results", oTemplate);
// bhtable.bindAggregation("items", "/VersBHeft/oData/results", oTemplate);
  console.log(sap.ui.getCore().byId("bheftPageId").byId("BHeftTable").getBindingContext("VersBHeft"));
  },
  error : function(err) {

  }
  };
  oModel.read("BonuseintragSet", params);
  }

}

This might show all the stuff that I tried to get the data into the table. The function gets called, when someone selects a field in the Master view. The table in the Detail view only shows No Data.....and it did this for hours.....

I read a lot other discussions about similar problems, but I have the problem, that I cannot transfer those solutions to my oData Structure. I guess that I am not addressing the data in the right way.

I am looking forward hearing from you 😊

Attachments

sap2.PNG (44.1 kB)