cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass parameter to getEntitySet from SAPUI5?

UlisesCasal
Explorer
0 Kudos

Hello everyone! I read the following post Solved: How to pass filter parameters to Get EntitySet fro... - SAP Community but it was not helpful. Basically, I need to pass a string as a parameter to my OData Gateway (getEntitySet) to bring a set of data filtered by said string from a Z table. My code for my controller in SAPUI5 is as follows:

 

var oFilterN = new Filter('FilterExample', FilterOperator.EQ, oExample);

var oParams = {
  filters: [oFilterN]
}
var oFilter = "/GetEntitySetExample";

oModel.read(oFilter, oParams, {
   success: function(oData){
      var oDataObtained = oData;
      var oModel = new JSONModel(oData);
      this.getView().setModel(oModel, "modelExample");
   }.bind(this),
    error: function(oError){}

});

 

(In the gateway service, I manage to obtain the parameter with this code, but it never enters the success or error of the controller in sapui5, so it does not allow me to obtain the data set)

And the code for my gateway service is as follows:

 

method getEntitySetExample_get_entityset.
  DATA: my_filter_options type /iwbep/t_mgw_select_option,
  lv_param type ztable-keycamp.
  READ TABLE it_filter_select_options INTO DATA(ls_filter) INDEX 1.
  lv_param = ls_filter-select_options[ 1 ]-low.
  select * from ZTABLE INTO CORRESPONDING FIELDS OF TABLE et_entityset WHERE keycamp EQ lv_param.
endmethod.

 

 

UlisesCasal
Explorer
0 Kudos
I also add that I have no errors in the web browser console. Thank you all!!!

Accepted Solutions (0)

Answers (1)

Answers (1)

david_bizer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

to understand you correct, you just want to use a basic filter like you showed in your provided code?

Regarding your code: 

 

The read function has only two parameters : The path and parameters. (https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/read)

Check if this code works (assuming oExample is a String):

 

var oFilterN = new Filter('FilterExample', FilterOperator.EQ, oExample);

var sPath = "/GetEntitySetExample";

oModel.read(sPath, {
   filters: [oFilterN],
   success: function(oData){
      var oDataObtained = oData;
      var oModel = new JSONModel(oData);
      this.getView().setModel(oModel, "modelExample");
   }.bind(this),
    error: function(oError){}

});