May 19

OData Basics – Part 3 (Filter Query Operation)

Query Operation on OData service, Continuation to blog OData Basics – Part 2

2017-05-19 22_43_46-183.82.114.111_3333 - Remote Desktop Connection

Right click on data provider extension class ZCL_ZRZ_SCARR_DEMP_DPC_EXT and navigate to workbench:

2017-05-19 22_44_22-183.82.114.111_3333 - Remote Desktop Connection

Redefine below highlighted method SCARRSET_GET_ENTITYSET:

2017-05-19 22_47_55-183.82.114.111_3333 - Remote Desktop Connection

Exporting parameter ET_ENTITYSET should be populated with data in this method:

2017-05-19 22_49_46-183.82.114.111_3333 - Remote Desktop Connection

Activate and test the changes:

2017-05-19 22_50_29-183.82.114.111_3333 - Remote Desktop Connection2017-05-19 22_50_56-183.82.114.111_3333 - Remote Desktop Connection

If I just give entity set name in URL parameters, complete data is retrieved from SCARR:

2017-05-19 22_53_27-183.82.114.111_3333 - Remote Desktop Connection

We can also make use of filter parameters IT_FILTER_SELECT_OPTIONS or IV_FILTER_STRING:

2017-05-19 23_00_39-183.82.114.111_3333 - Remote Desktop Connection

Check URL Conventions to know the possibilities of using URL parameters..

For instance, using logical operators while applying filter:

2017-05-19 23_14_36-URL Conventions (OData Version 3.0) · OData - the Best Way to REST

Using single value in filter:
<Entity Set>?$filter=<Attribute> eq '<value>'
SCARRSet?$filter=Carrid eq 'LH'

2017-05-19 23_16_44-183.82.114.111_3333 - Remote Desktop Connection

2017-05-19 23_18_31-183.82.114.111_3333 - Remote Desktop Connection

2017-05-19 23_19_06-183.82.114.111_3333 - Remote Desktop Connection

Using multiple values in filter:
<Entity Set>?$filter=<Attribute> eq '<value>'
SCARRSet?$filter=Carrid eq 'AA' or Carrid eq 'LH'

2017-05-19 23_21_21-183.82.114.111_3333 - Remote Desktop Connection2017-05-19 23_22_18-183.82.114.111_3333 - Remote Desktop Connection

2017-05-19 23_23_16-183.82.114.111_3333 - Remote Desktop Connection