Skip to Content

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

How to bind result of oModel.callFunction - Get to Table?

Hi, recently I´ve started with SAPUI5 and SAP Gateway, I´ve ready my first service using Sap Gateway, now I´m trying to bind the result of my service in a table, I can watch the result of my HEADERDATASET_GET_ENTITYSET method, now I want use a call function that I´ve defined "Materiales"

I´ve launched using the client in SAP and it´s working properly and with the debugging in the SAPUI5 page I can see that a dataset of results is coming that come from my /IWBEP/IF_MGW_APPL_SRV_RUNTIME~EXECUTE_ACTION in my DPC_EXT class, buy now I don´t know what I must do to bind this data in my table, something Í´ve forgotten or missing it because I´dont know, any help ????

My table all the time only have the result of the method HEADERDATASET_GET_ENTITYSET .

I can see in the console that the function is returning the data that I need it.


Thanks in advance...

My code..

var oTable = new sap.ui.table.Table({

  editable: false,

  toolbar: new sap.ui.commons.Toolbar({

  items: [

  new sap.ui.commons.Button({

  text: "Create user",

  press: function() {

  openCreateDialog();

  },

  }),

  new sap.ui.commons.Button({

  text: "Update user's data",

  press: function() {

  var idx = oTable.getSelectedIndex();

  if (idx == -1) return;

  var rows = oTable.getRows();

  var user = rows[idx].getCells();

  openUpdateDialog(user);

  },

  }),

  new sap.ui.commons.Button({

  text: "Delete user",

  press: function() {

  var idx = oTable.getSelectedIndex();

  if (idx == -1) return;

  var rows = oTable.getRows();

  var user = rows[idx].getCells();

  openDeleteDialog(user[0].getValue());

  },

  })

  ]

  }),

  });

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "ProductId"}),

  template: new sap.ui.commons.TextField().bindProperty("value", "ProductId"),

  editable: false,

  sortProperty: "ProductId"

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "TypeCode"}),

  template: new sap.ui.commons.TextField().bindProperty("value", "TypeCode"),

  sortProperty: "TypeCode",

  editable: false,

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "Category"}),

  template: new sap.ui.commons.TextField().bindProperty("value", "Category"),

  sortProperty: "Category",

  editable: false,

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "Name"}),

  template: new sap.ui.commons.TextField().bindProperty("value", "Name"),

  sortProperty: "Name",

  editable: false,

  }));

  

  oTable.addColumn(new sap.ui.table.Column({

  label: new sap.ui.commons.Label({text: "Description"}),

  template: new sap.ui.commons.TextField().bindProperty("value", "Description"),

  sortProperty: "Description",

  editable: false,

  }));

  var oModel = new sap.ui.model.odata.ODataModel("http://desarrollo.grupopanasa.com:8000/sap/opu/odata/sap/Z_PRUEBA_BAPI_SRV/", false, "user", "password");

  sap.ui.getCore().setModel(oModel);

  oModel.callFunction("Materiales", // function import name 

                                "GET", // http method 

                               { ProductId : 'AA'  }, // function import parameters 

                                null,  

                               

                                function(oData, oResponse) {

                             

                              console.log(oResponse);

                              console.log(oData); 

                              alert("ok");

                                                              

                                }, // callback function for success 

                                function(oError){

                                alert("err")

                                } ); // callback function for error

  oModel.refresh(true);

  oTable.bindRows("/HeaderdataSet");

  oTable.placeAt("content");

Former Member
replied

function(oData, oResponse) {

                            

                                                       

oTable.setModel(

new sap.ui.model.json.JSONModel({ data : oData.results });


)bindRows("/data");


                                }, // callback function for success

2 View this answer in context

Helpful Answer

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