03-10-2021 9:58 PM
Hi,
I have a CDS Based Odata service with a virtual element that I calculate using an ABAP Class.
I need to use filters on this oData so I found that I need to create a class implementing (if_sadl_exit_filter_transform) and its method ( map_atom )
But even after that I still have the same error : The calculated field XXXX cannot be used in filters
My interface implementing map_atom :
CLASS zff_filter_xx DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_sadl_exit_filter_transform .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zff_filter_rc IMPLEMENTATION.
METHOD if_sadl_exit_filter_transform~map_atom.
DATA(lv_xx) = cl_sadl_cond_prov_factory_pub=>create_simple_cond_factory( )->element( 'XX' ).
ro_condition = lv_xx->covers_pattern( '*abc*' ).
ENDMETHOD.
ENDCLASS.
03-11-2021 7:33 AM
As the message says no filter can be applied on a virtual element in that method.
The meaning of the method is, that when you want to use filtering on a virtual element, you have to transform the virtual filter to a filter condition on real (not virtual) CDS elements. The filter is then applied when the query is applied on db.
The example provided here in the documentation should make it more understandable for you.
06-02-2023 3:34 PM
Florian,
when you say: The filter is then applied when the query is applied on db
the problem is that the filter for the virtual element takes into account the real CDS element.
Where can it takes into account the virtual element then?.
Thanks,
Javier