Gyan Factory

Gyan Factory
SAP Technical Project Support

Tuesday, January 5, 2016

FOR Loop in ABAP !

DATA lt1 TYPE TABLE OF spfli.

SELECT FROM spfli INTO TABLE lt1.

LOOP AT lt1 ASSIGNING FIELD-SYMBOL(<fs1>).
  WRITE :/ <fs1>-carrid<fs1>-connid<fs1>-cityfrom<fs1>-cityto.
ENDLOOP.
ULINE.

TYPES lt2 TYPE TABLE OF spfli WITH EMPTY KEY.

DATA(lt2VALUE lt2(
                   FOR ls IN lt1 WHERE (  carrid 'LH' )
                      carrid ls-carrid
                        connid ls-connid
                        cityfrom ls-cityfrom
                        cityto ls-cityto ).

LOOP AT lt2 ASSIGNING FIELD-SYMBOL(<fs2>).
  WRITE :/ <fs2>-carrid<fs2>-connid<fs2>-cityfrom<fs2>-cityto .
ENDLOOP. 


--------------------------------------------------------------------------------------------------------------------------
------
The FOR Loop runs on the table LT1 with a condition and put backs the record to LT2.






--------------------------------------------------------------------------------------

No comments:

Post a Comment