Ahmed
Ahmed

Reputation: 43

Passing filters in OData service SAP UI5 to ABAP

I am reading two parameters from URL.

 var spayid = jQuery.sap.getUriParameters().get("payid"); 
 var spaydt = jQuery.sap.getUriParameters().get("paydt");

Now I have to pass these two filter options in my odata service.

this.getView().setModel(new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/Z_OD_SRV/?sap-client=100", {    
json : true,
useBatch : false})

Entity Name= PDetailSet Field name for spayid is Laufid and spaydt is Laufdt.

Please help how to pass filters in odata service.

NB: I have also add the filters in the following way.

var filter1= new sap.ui.model.Filter(
    { path: "Laufi", operator: sap.ui.model.FilterOperator.EQ, value1: spayid });
var filter2= new sap.ui.model.Filter(
    { path: "Laufd", operator: sap.ui.model.FilterOperator.EQ, value1: spaydt });

Upvotes: 0

Views: 2297

Answers (1)

Jan W
Jan W

Reputation: 958

A model itself can not be filtered, but a binding can. So if you bind your dataset to a table i.e. you could filter that binding with your filters, as described in your comments.

That would look like this:

oTable.getBinding("rows").filter(filter1);

To combine your two filters, you can use another filter, which has the advantage that you can decide wheter to use "and" or "or". You can see a detailed example for that in the documentation.

Upvotes: 2

Related Questions