FILTER on Internal Table with EXCEPT addition

R6AbMo1465374608 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

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
* 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_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.


6

Output

Content of LT_SPFLI1 .

4

After FILTER with EXCEPT on the table LT_SPFLI1, the content of LT_SPFLI2 as below.

5


 

Leave a Reply