2 weeks ago
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.
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){}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
9 | |
9 | |
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.