Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Odata

472

I want to pass different fields values using filter in odata query of abap.

/sap/opu/odata/SAP/ZISD052_ATP_SRV/ATPSet?$filter=(Plant eq '0572' or View eq 'ZTALLY' or Uom eq 'PCE')&$format=json

But it is throwing error, can you please help me with query.

Thanks in advance

4 REPLIES 4

junwu
Active Contributor
0 Kudos
391

what error?

0 Kudos
391

Please pass VIEW in Query

SowmyaSurekha
Explorer
0 Kudos
391

Hi siri_42,

you have to use "and" not "or"

/sap/opu/odata/SAP/ZISD052_ATP_SRV/ATPSet?$filter=(Plant eq '0572' and View eq 'ZTALLY' and Uom eq 'PCE')&$format=json

thank regards,

sowmya.

Patrice
Participant
0 Kudos
391

Hi K,

This request will call a Method in the generated ODATA Class. The Class name will be something like ZCL_ISD052_ATP_DPC_EXT. The Method called by this specific request will be something like ATPSET_GET_ENTITYSET. In this Method you usually receive your filters in importing parameter IT_FILTER_SELECT_OPTIONS, with each property of the filter being separated in different records of this table. If you use "or" to search different values on the same property, it will be able to group them in one record of IT_FILTER_SELECT_OPTIONS. But if you use "or" between different properties, it will not be able to parse your filter string and IT_FILTER_SELECT_OPTIONS will be received empty.

In addition to this parameter, there is also the importing parameter IV_FILTER_STRING. This will always be filled when specifying a filter, even if it is not able to parse it and fill IT_FILTER_SELECT_OPTIONS. So if you must use "or" to compare different properties in your filter, you will need to adapt the code of your Method so that you do the parsing of IV_FILTER_STRING yourself.

I hope this helps.

Patrice Poirier