For Loop In ABAP-2

d9Q4e1470048781 For Loop can be efficiently use in stead of LOOP…..ENDLOOP for internal table filter.

 

 

 

CODE


DATAlt_flight TYPE flighttab.
SELECT FROM sflight INTO TABLE lt_flight .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SFLIGHT’
  TABLES
    t_outtab           lt_flight.
* FIlters out all records from lt_flight where CARRID = ‘AZ’
DATA(lt_flight_subVALUE flighttabFOR ls_flight IN lt_flight
                                                                                 WHERE carrid ‘AZ’ ) ls_flight )
                                                                             ).

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SFLIGHT’
  TABLES
    t_outtab           lt_flight_sub.


OUTPUT

LT_FLIGHT content in ALV

2

LT_FLIGHT_SUB content in ALV.3


CODE


DATAlt_flight TYPE flighttab.
SELECT FROM sflight INTO TABLE lt_flight .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SFLIGHT’
  TABLES
    t_outtab           lt_flight.

* WITH MULTIPLE CONDITIONS
DATA(lt_flight_subVALUE flighttabFOR ls_flight IN lt_flight
                                        WHERE carrid ‘AZ’ AND connid ‘789’ ) ls_flight )
                                                                            ).

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
  EXPORTING
    i_callback_program syrepid
    i_structure_name   ‘SFLIGHT’
  TABLES
    t_outtab           lt_flight_sub.


OUTPUT- LT_FLIGHT_SUB content in ALV.

4.jpg


 

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