ABAPAT_ITAB - AT ITAB

General Material Data   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

AT - itab

Short Reference



Syntax

LOOP AT itab result ...
  [AT FIRST.
     ...
   ENDAT.]
    [AT NEW comp1.
       ...
     ENDAT.
      [AT NEW comp2.
         ...
       ENDAT.
         [...]]]
           [ ... ]
       [[[...]
       AT END OFcomp2.
         ...
       ENDAT.]
     AT END OF comp1.
       ...
     ENDAT.]
  [AT LAST.
     ...
  ENDAT.]
ENDLOOP.

Additions

1. ...  FIRST

2. ... {NEW}|{END OF} compi

3. ...  LAST

Effect

The statement block of a LOOP loop can contain control structures forcontrol level processing. The corresponding control statement is AT. The statements AT and ENDAT define statement blocks that are executed atcontrolbreaks, that is, when the control structure is changed. The additions of the AT statementsdetermine the control break at which their statement blocks are executed. Within these statement blocks,the statement SUMcan be specified to total the numeric components of a control level. For the output behavior result,the same applies as for LOOP AT.

The prerequisite for control level processing is that the processing sequence in which the LOOPloop reads the rows of the internal table is sorted in the exact order of the components of its rowtype, that is, firstly in accordance with the first component, then in accordance with the second component,and so on. The row structure and the corresponding sorting sequence creates a group structure of thecontent of the internal table, whose levels can be evaluated using AT statements. The AT-ENDAT control structures must be aligned one after the other, in accordance with the group structure.

The statement blocks within the AT-ENDAT control structures are executed if an appropriatecontrol break is made in the current table row. Statements in the LOOP-ENDLOOP controlstructure that are not executed within an AT-ENDAT control structure are executed in each pass of the loop.

To ensure that control level processing is carried out properly, the following rules must be observed:

  • A table key specified for LOOP in condmust be chosen so that it produces the required sort order of the imported rows.

  • A restricting condition specified for LOOP in condmust select a contiguous block of rows from the internal table. Otherwise the behavior of the control level processing is undefined.

  • The internal table cannot be modified within the LOOP loop.

  • A work area wa specified in the LOOP statement after the addition INTO must becompatible with the row type of the table.

  • A field symbol <fs> specified in the statement LOOP after the addition ASSIGNING must be typed with the row type of the table.

  • The content of a work area wa specified in the statement LOOP after the addition INTO cannot be modified.

If the addition INTO is used in the statement LOOPto assign the content of the current row to a work area wa, its content is modified as follows when the AT-ENDAT control structure is entered:

  • The components of the current control key remain unchanged.

  • All components with a character-like flat data type to the right of the current control key are set to character "*" in every position.

  • All the other components to the right of the current control key are set to their initial value.

When the AT-ENDAT control structure is exited, the content of the current table row is assigned to the entire work area wa.

Example

See Control Level Processing.

Addition 1

...  FIRST

Effect

The control level is defined by the first row of the internal table. The control break takes place when this row is read.

Note

In the group level AT FIRST, the current group key contains no components and all character-likecomponents of the work area wa are filled with "*" and all remaining components are set to their initial value.

Addition 2

... {NEW}|{END OF} compi

Effect

Control levels are defined by the beginning or end of a group of rows with the same content in the componentcompi (where i = 1, 2, and so on) and in the components to the left of compi.The control breaks take place when the content of the component compi or another component to the left of compi changes.

The compi components can be specified as described inSpecification ofComponents, with the limitation that access to data objects using references is not possible here. The following is therefore not possible:

  • Specifying data objects using data references
  • Specifying attributes of objects using object references

Otherwise, the specified components can have any data type. The relevant comparison rules apply to the evaluation.

Note

If the INTO or ASSIGNING additions are used in the LOOP statement, a field symbolcan be entered after AT {NEW}|{END OF} outside classes. The corresponding component of the workarea wa or the field symbol <fs> is assigned to this field symbol. This form of specifyingcomponents dynamically is obsolete and has been replaced by the format (name).

Addition 3

...  LAST

Effect

The control level is defined by the last row of the internal table. The control break takes place when this row is read.

Note

In the group level AT LAST, the current group key contains no components and all character-likecomponents of the work area wa are filled with "*" and all remaining components are set to their initial value.

Exceptions

Non-Catchable Exceptions

  • Cause: Invalid subfield access with dynamic specification of the control break criterion.
    Runtime Error: AT_BAD_PARTIAL_FIELD_ACCESS
  • Cause: The control break criterion is specified dynamically using the field symbol and the field symbol does not point to the LOOP output area.
    Runtime Error: AT_ITAB_FIELD_INVALID
  • Cause: The control break criterion is specified dynamically using (name) and the name field does not contain a valid subfield label.
    Runtime Error: ITAB_ILLEGAL_COMPONENT
  • Cause: Overflow of totals with SUM.
    Runtime Error: SUM_OVERFLOW







rdisp/max_wprun_time - Maximum work process run time   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.


Length: 10962 Date: 20120518 Time: 193437     triton ( 279 ms )