FOR Loop in ABAP

DATA lt1 TYPE TABLE OF spfli.

SELECT FROM spfli INTO TABLE lt1.

LOOP AT lt1 ASSIGNING FIELDSYMBOL(<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 lscarrid
connid lsconnid
cityfrom lscityfrom
cityto lscityto ).

LOOP AT lt2 ASSIGNING FIELDSYMBOL(<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.


 

 

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