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: 

Filter CDS Based Odata service on Virtual Calculated Element

raskolnico
Explorer

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.
2 REPLIES 2

pfefferf
Active Contributor
0 Kudos

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.

0 Kudos

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