Ansicht
Dokumentation

ABAPLOOP_AT_ITAB_RESULT - LOOP AT ITAB RESULT

ABAPLOOP_AT_ITAB_RESULT - LOOP AT ITAB RESULT

BAL_S_LOG - Application Log: Log header data   Vendor Master (General Section)  
This documentation is copyright by SAP AG.
SAP E-Book

LOOP AT itab, result

Short Reference



... ${ INTO wa $}
  $| ${ ASSIGNING <fs> $[CASTING$] $}
  $| ${ REFERENCE INTO dref $}
  $| ${ TRANSPORTING NO FIELDS $} ...

Effect

Defines the output behavior of a LOOP across an internal table. There are four alternatives for the output behavior:

  • The addition INTO is used to assign the content of the current line to a work area wa.
  • The addition ASSIGNING is used to assign the current line to a field symbol <fs>. No other memory area can be assigned to the field symbol within the loop and the assignment cannot be undone using UNASSIGN.
  • The addition REFERENCE INTO is used to create a reference to the current line in a reference variable. No other reference can be assigned to the reference variable within the loop and the reference variable cannot be initialized using CLEAR.
  • The addition TRANSPORTING NO FIELDS specifies that only the relevant system fields are filled. This addition is only possible if the addition WHERE is used in the conditions cond at the same time and if the addition GROUP BY is not used.

If the internal table itab is specified as an existing data object, the syntax and meaning of the specified output behavior is the same as in the statement READ TABLE, with the exception that no further transport_options can be specified after INTO wa, and the same restrictions apply to modifications of key fields of the primary and secondary table keys. In particular, inline declarations for the work area, the field symbol, or the reference variable using the declaration operators DATA, FINAL, and FIELD-SYMBOL are possible.

If a field symbol or a dereferenced reference variable is specified for the work area wa or the reference variable dref, the target data object of the field symbol or reference variable is determined in each loop pass. The current data object is used as the target area for each loop pass. This means that changes in the assignment of the field symbol or reference variable within the loop modify the target area.

If the internal table is specified as the return value of a functional method, a constructor expression, or a table expression, the additions ASSIGNING and REFERENCE INTO can also be specified for LOOP, unlike in READ TABLE. The internal table is only available while the loop is being processed, which means that all field symbols and reference variables that point to lines in the internal table become invalid when the loop is exited.

Output Behavior

Notes

  • If the current line is deleted within the loop when the additions ASSIGNING or REFERENCE are used, the field symbol or reference variable is not assigned or unbound in the current loop pass afterwards.
  • For LOOP, there is an obsolete short form outside of classes, where INTO wa can be omitted if the internal table has an identically named header line itab. INTO itab is then added to the statement.

Example

Two LOOP loops are used to determine the line numbers for numbers greater than or equal to 40 and less than or equal to 60 in a sorted table of random numbers, and the addition TRANSPORTING NO FIELDS is used. Then, INTO is used to read these lines to a variable number. Filling the output table in this way demonstrates the use of number. It could also be done using INSERT LINES OF.

Example

Loop across an internal table containing dates. The table lines are assigned to a structured field symbol with a corresponding casting.






General Data in Customer Master   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 6020 Date: 20240329 Time: 000247     sap01-206 ( 71 ms )