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


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s