FILTER without EXCEPT addition selects those rows that matches the where condition while FILTER with EXCEPT selects those rows that don’t matches the where condition.
FILTER with EXCEPT addition can be applied on internal tables with secondary key. FILTER without EXCEPT addition selects those rows that matches the where condition while FILTER with EXCEPT selects those rows that don’t matches the where condition.
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
* EXCEPT addition keeps the rows that don't match the WHERE condition.
lt_spfli2 = FILTER #( lt_spfli1 EXCEPT 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
Content of LT_SPFLI1 .
After FILTER with EXCEPT on the table LT_SPFLI1, the content of LT_SPFLI2 as below.