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
DATA: lt_spfli1 TYPE TABLE OF spfli WITH NON-UNIQUE SORTED KEY key1
COMPONENTS countryfr,
lt_spfli2 TYPE TABLE OF spfli,
countryfr TYPE spfli–countryfr 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_upper( countryfr ) )
).
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy–repid
i_structure_name = ‘SPFLI’
TABLES
t_outtab = lt_spfli1.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy–repid
i_structure_name = ‘SPFLI’
TABLES
t_outtab = lt_spfli2.
Output