I am creating a SAPUI5 application. This application is connected to a backend SAP system via OData. In the SAPUI5 application I use a smart chart control. Out of the box the smart chart lets the user create filters for the underlying data. This works fine - except if you try to use multiple 'not equals' for one property. Is there a way to accomplish this?
I found out that all properties within an 'and_expression' (including nested or_expressions) must have unique name.
The reason why two parameters with the same property don't get parsed into the select options:
/IWCOR/CL_ODATA_EXPR_UTILS=>GET_FILTER_SELECT_OPTIONS
takes the expression you pass and parses it into a table of select options.The select option table returned is of type
/IWCOR/IF_ODATA_TYPES=>EDM_SELECT_OPTION_T
which is aHASHED TABLE .. WITH UNIQUE KEY
property.
From: https://archive.sap.com/discussions/thread/3170195
The problem is that you cannot combine NE
terms with OR
. Because both parameters after the NE
should not be shown in the result set.
So at the end the it_filter_select_options
is empty and only the iv_filter_string
is filled.
Is there a manual way of facing this problem (evaluation of the iv_filter_string
) to handle multiple NE
terms?
This would be an example request:
XYZ/SmartChartSet?$filter=(Category%20ne%20%27Smartphone%27%20and%20Category%20ne%20%27Notebook%27)%20and%20Purchaser%20eq%20%27CompanyABC%27%20and%20BuyDate%20eq%20datetime%272018-10-12T02%3a00%3a00%27&$inlinecount=allpages
Normally I want this to exclude items with the category 'Notebook' and 'Smartphone' from my result set that I retrieve from the backend.
(Category ne 'Smartphone' and Category ne 'Notebook') and Purchaser eq 'CompanyABC' and BuyDate eq datetime'2018-10-12T02:00:00'
. Also the variable names you mentioned are confusing./iwcor/cl_odata_expr_utils=>get_filter_select_options
receivesiv_expression
and returnsrt_select_options
. I am posting a possible answer now. fix me if i didn't get you. – Dorad