Application Development and Automation 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: 
Read only

Filtering a dynamic table

mpj
Product and Topic Expert
Product and Topic Expert
0 Likes
1,833

Hi all,

I have a scenario where I need to filter a dynamic table (say, a data table) based on another ID table (say, key table). Is this possible?

The following code snippet is an example of what I am trying to do.

     DATA:   lt_flight TYPE STANDARD TABLE OF sflight,

             lt_carr   TYPE STANDARD TABLE OF scarr,

             lt_data   TYPE REF TO DATA.

     FIELD-SYMBOLS: <lt_data> TYPE ANY TABLE.

     SELECT * FROM sflight INTO TABLE lt_flight.

     SELECT * FROM scarr INTO TABLE lt_carr.

    

           CREATE DATA lt_data TYPE sfligt.

     ASSIGN lt_data->* TO <lt_data>.

     MOVE-CORRESPONDING lt_flight TO lt_data.

     DATA(lt_temp_data) = FILTER #( <lt_data> IN mt_carr WHERE ('CARRID') = carrid ).

<lt_data> can take any table data and the filtering needs to be done on the same. Also please note that 'lt_data' is also another generic table.

Right now, I am getting a syntax error:  "The type or field "%_ANY_TABLE" is generic. The access types "ANY TABLE" or "INDEX TABLE" can only be used for parameters" pointing to the last line.


Is there anyway we can make this filtering possible?

1 REPLY 1
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,180

Hi,

You cannot use generic table types(in your case <lt_data> TYPE ANY TABLE ) with FILTER.

Refer : ABAP Keyword Documentation

BR,

Suhas