LOOP AT dbtab [VERSION vers].
...
ENDLOOP.
The statements LOOP and ENDLOOP define a loop around a statement block (not allowed in classes). For dbtab, you must specify a database table that begins with "T" and has a maximum length of five characters. For the database table dbtab, a table work area must be declared with the TABLES> statement.
In each loop run, the statement LOOP reads a line from the database table dbtab and assigns its content to the table work area. The lines to be read are determined by the content of the components of the table work area, which correspond with the primary key fields of the database table dbtab. Before the first loop run, the content of these components is taken as the search key, reading from the left, and the database table is searched generically for suitable entries. In the search key, blank characters are treated as if they agree with all values.
If a database table is specified that does not start with "T", then the first letter is implicitly replaced by "T". The loop is not executed if the database table does not exist
System Fields
sy-subrc | Meaning |
12 | The database table has not been found. |
... VERSION vers
If the addition VERSION is specified, the database
dbtab is not read; instead, the table with a name made up of "T" and the content of
vers is read. For vers a data object with a
maximum of four characters, of type c must be specified.
The content of the row is still assigned to the table work area of dbtab and its type is cast. If the table work area is too short, a runtime error occurs.
Sequential reading of rows from database table T100.
TABLES t100.
t100 = space.
t100-sprsl = 'E'.
t100-arbgb = 'BC'.
t100-msgnr = '1'.
LOOP AT t100.
...
ENDLOOP.
The Open-SQL-Syntax to be used instead reads:
DATA wa TYPE t100.
SELECT *
FROM t100
INTO wa
WHERE sprsl = 'E' AND
arbgb = 'BC' AND
msgnr LIKE '1%'.
...
ENDSELECT.