ABAP Keyword Documentation → ABAP - Quick Reference
LOOP AT itab - Quick reference
Other versions: 7.31 | 7.40 | 7.54
Syntax
LOOP AT itab { { INTO wa }
| { ASSIGNING <fs> [CASTING] }
| { REFERENCE INTO dref }
| { TRANSPORTING NO FIELDS } }
[ USING KEY key_name|(name) ]
[ FROM idx1] [TO idx2][WHERE
log_exp|(cond_syntax) ]
[ GROUP BY key | ( key1 = dobj1 key2 = dobj2 ...
[gs = GROUP SIZE] [gi = GROUP INDEX] )
[ASCENDING|DESCENDING [AS TEXT]]
[WITHOUT MEMBERS]
[ {INTO group}
| {ASSIGNING <group>}
| {REFERENCE INTO group_ref} ] ].
...
ENDLOOP.
Effect
Reads an internal table itab
in a loop. A restricted
variant works withmesh paths.
Additions
-
INTO wa
Assigns the read row to a work areawa
. -
ASSIGNING <fs> [CASTING]
Assigns the row (read from internal table) to a field symbol<fs>
, where casting can be performed. -
REFERENCE INTO dref
Assigns a reference to the row (read from internal table) to a reference variabledref
. -
TRANSPORTING NO FIELDS
Does not assign the read row. -
USING KEY key_name|(name)
Statically or dynamically specifies a (secondary) table key that determines the processing order. -
[FROM idx1] [TO idx2] [WHERE log_exp|(cond_syntax)]
Restricts the rows to be read, by declaring a lower number and upper number (idx1
andidx2
in the relevant table index), or by declaring a static conditionlog_exp
or a dynamic condition incond_syntax
. -
GROUP BY ...
Groups the rows in the internal table by a group key and executes a loop across the groups.ASCENDING|DESCENDING
sorts the groups; WITHOUT MEMBERS suppresses the grouping variant for the table rows;INTO GROUP
, ASSIGNING, andREFERENCE INTO
define the output behavior of the group loop.