Skip to Content

$filter with 'and' / 'or' options for select query

Dear Experts,

I have following query to handle filter options in entityset, and in the entityset, filter parameters are filled in the importing parameter - IT_FILTER_SELECT_OPTIONS and I have logic based on this internal table. And it works fine.

/sap/opu/odata/sap/ZBW_CUSTSEL_SRV/CUSTOMERSet?$filter=( Customer eq '32' and Name eq 'AT' )&$orderby=Name&$format=json

But When I use 'OR' instead of 'AND' then the system does not fill the filter parameters in IT_FILTER_SELECT_OPTIONS. What is the reason for this behavior.

I know that in both cases IV_FILTER_STRING filled, but then I have to slit this string and make sure of operators so on.

Thank you,


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 15, 2016 at 12:32 PM

    Hello Murali,

    When you are passing different fields as part of Filter parameters you need to use AND only ( which is as below as per your URL )

    ?$filter=Customer eq '32' and Name eq 'AT'

    When you want to pass multiple values for the same fields as part of Filter parameters you can use OR in combination with AND as below

    ?$filter=( Customer eq '32' or Customer eq '33' ) and ( Name eq 'AT' or Name eq 'BT' )

    ?$filter=( Customer eq '32' or Customer eq '33' )

    ?$filter=( Name eq 'AT' or Name eq 'BT' )



    Add a comment
    10|10000 characters needed characters exceeded

    • Mike Reader Murali Krishna Pinnamaneni

      Hi Murali,

      I did notice that IV_FILTER_STRING had our condition, I am not sure it is feasible to parse through that to come up with our parameters.

      I believe pure Odata gives us the option to use AND and OR properly as shown from my example at

      http://host/service/Products?$filter=Name eq 'Milk' or Price lt 2.55

      What we seem to be facing is a limitation in how the parameters are interpreted on the SAP side due to the use of the select options table (IT_FILTER_SELECT_OPTIONS).

      We have to decide we if want to do an AND or an OR with our select and not base it on the filters being passed.


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.