Ansicht
Dokumentation

ABENFOR_ITAB - FOR ITAB

ABENFOR_ITAB - FOR ITAB

Vendor Master (General Section)   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

FOR, Table Iterations

Read lines of internal tables

1. ... FOR wa$|<fs> IN itab $[INDEX INTO idx$] $[ cond$] $[let_exp$]  ...

Group lines of internal tables

2. ... FOR GROUPS $[group$|group>$] OF wa$|<fs> IN itab
          $[INDEX INTO idx$] $[cond$]
          GROUP BY group_key
          $[ASCENDING$|DESCENDING $[AS TEXT$]$]
          $[WITHOUT MEMBERS$]
          $[let_exp$] ...


Read group members of internal tables

3. ... FOR ${ wa$|<fs> IN GROUP group $[INDEX INTO idx$] $[WHERE ( log_exp )$] $}
        $| ${ GROUPS OF
            wa$|<fs> IN GROUP group $[INDEX INTO idx$] $[WHERE ( log_exp )$]
            GROUP BY group_key
            $[ASCENDING$|DESCENDING $[AS TEXT$]$]
            $[WITHOUT MEMBERS$] $} $[let_exp$] ...


Effect

These syntax forms of an iteration expression using FOR perform table iterations.

  • When used in a constructor expression with the reduction operator REDUCE, these are known as table reductions.
  • When used in a constructor expression with the instance operator NEW or with the value operator VALUE for internal tables, these are known as table comprehensions.

A FOR expression like this evaluates the content of an internal table and its result can be used to construct the result of the wrapper constructor expression. The three variants of a FOR expression for internal tables work in the same way as the following variants of the statement LOOP AT itab:

The variables or field symbols declared in the FOR expressions are local here. The local data from all outer FOR expressions can be used when their values are defined. As an option, LET expressions let_exp can be specified to define local helper fields at the end of each FOR expression.

The system field sy-tabix is not set by a FOR expression. The addition INDEX INTO can be used instead.

Notes

  • Multiple consecutive FOR expressions with different variants (including the conditional iteration) can be specified in a constructor expression. These expressions then work in the same way as nested loops.
  • It is not allowed to clear or replace the complete table body of the internal table that is currently processed in a FOR expression. Any attempt leads to the runtime error TABLE_FREE_IN_LOOP.

Generation of an internal table jtab from an internal table itab using a table comprehension. Generation of a text string str from the internal table jtab using a table reduction. The result in str is the character string 1, 9, 25.






RFUMSV00 - Advance Return for Tax on Sales/Purchases   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 6407 Date: 20240329 Time: 131730     sap01-206 ( 70 ms )