ABAPLOOP_AT_DBTAB - LOOP AT DBTAB

General Material Data   Vendor Master (General Section)  
This documentation is copyright by SAP AG.

LOOP AT dbtab

Short Reference



Syntax

LOOP AT { dbtab | *dbtab } [VERSION vers].
  ...
ENDLOOP.

Addition:

... VERSION vers

Effect

The LOOP and ENDLOOP statements define a loop around a statement block (not permittedin classes). For dbtab, you must specify the name of a database table that begins with "T" and is no more than five characters long. For database table dbtab, atable work area or anadditional tablework area must be declared with the TABLES statement.

In each loop pass, the LOOP statement reads a row from database table dbtab and assignsits content either to the table work area or to the additional table work area if *dbtab is specified. The rows to be read are determined by the content of the components of the table work area used, which correspond to theprimarykey fields of database table dbtab. Before the first loop pass, the content of these componentsis 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 matches for all values.

If a database table is specified that does not start with "T", the first letter is replaced by "T" implicitly. The loop is not executed if the database table does not exist

System Fields

sy-subrcMeaning
12The database table was not found.

Notes

  • In Unicodeprograms, all components of the table work area that correspond with the primary key fields of database table dbtab must be character-like.
  • This form of the LOOP loop is not permitted in classes. It must be replaced with the SELECT statement.
  • The obsolete access statements do not support automaticclient handling. Theclientidentifier of a database table must be specified explicitly. The application programs are only to work with data for the current client. In systems withmultitenancy, this is checked by the ABAP runtime environment.


Addition

... VERSION vers

Effect

If the VERSION addition is specified, database dbtab is not read; instead, the table witha name made up of "T" and the content of vers is read. For vers, a data object must bespecified with a name that is no more than four characters long and that is of type c. The contentof the row is still assigned to the table work area of dbtab or *dbtab and its type is cast. If the table work area is too short, a runtime error occurs.

Example

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 is:

DATA wa TYPE t100.

SELECT *
       FROM t100
       INTO wa
       WHERE sprsl = 'E'  AND
             arbgb = 'BC' AND
             msgnr LIKE '1%'.
  ...
ENDSELECT.


ABAP Short Reference   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.


Length: 5217 Date: 20120523 Time: 000501     triton ( 159 ms )