2023 Jul 13 4:31 PM
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
2023 Jul 13 5:14 PM
2023 Jul 13 5:49 PM
2023 Jul 17 7:56 AM
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.
2023 Jul 18 4:56 PM
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