Ansicht
Dokumentation

ABAPLOOP_AT_DBTAB - LOOP AT DBTAB

ABAPLOOP_AT_DBTAB - LOOP AT DBTAB

BAL Application Log Documentation   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.
SAP E-Book

LOOP AT dbtab

Short Reference



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

Addition:

... VERSION vers

Effect

The statements LOOP and ENDLOOP define a loop around a statement block, which is forbidden in classes. dbtab expects a database table or DDIC table view that starts with "T" and has a maximum length of five characters. For the database table or view dbtab, a table work area or an additional table work area must be declared using the statement TABLES. All components of the table work area that match the primary key fields of the database table or view dbtab must be character-like.

In each loop pass, the statement LOOP reads a row from the database table or view dbtab and assigns its content either to the table work area, or if *dbtab is specified, to the additional table work area. The rows to be read are determined by the content of the components of the table work area that match the primary key fields of the database table or view dbtab. Before the first loop pass, the content of these components is taken left-aligned as the search key and the database table or view is searched generically for suitable entries. The search key handles blanks as if they match all values.

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

System Fields

sy-subrc Meaning
12 The database table or view was not found.

Notes

  • This form of the LOOP-loop is not allowed in classes. It must be replaced by the SELECT statement.

  • The obsolete access statements do not support automatic client handling. The client identifier of a database table must be specified explicitly. The application programs are only to work with data for the current client. In systems with multitenancy, this is checked by the ABAP runtime environment.


Addition

... VERSION vers

Effect

If the addition VERSION is specified, the database table or view dbtab is not read, and the table or view whose name is composed of "T" and the content of vers is read instead. vers expects a data object with a maximum of four characters, of type c. The content of 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 syntax to be used instead reads:






CL_GUI_FRONTEND_SERVICES - Frontend Services   ABAP Short Reference  
This documentation is copyright by SAP AG.

Length: 4608 Date: 20240616 Time: 110156     sap01-206 ( 82 ms )