FILTER on Internal Table

Bdz4Ol1465365380

With the new ABAP feature FILTERing can be applied on internal tables with secondary key which reduces the LOOPing on the internal tables to find out the matching records on a particular field(s). The below post shows how to work with new FILTER technique.

 

Program

DATAlt_spfli1 TYPE TABLE OF spfli WITH NON-UNIQUE SORTED KEY key1
                                                                          COMPONENTS countryfr,
              lt_spfli2 TYPE TABLE OF spfli,
              countryfr TYPE spflicountryfr VALUE ‘US’.
SELECT FROM spfli INTO TABLE lt_spfli1.

* FILTERING is applied only on internal tables with secondary key
lt_spfli2 =   FILTER #lt_spfli1 USING KEY key1
                        WHERE countryfr CONV #to_uppercountryfr )
                       ).
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SPFLI’
  TABLES
    t_outtab           lt_spfli1.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SPFLI’
  TABLES
    t_outtab           lt_spfli2.


1

Output

23


 

Leave a Reply