Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete User Dialogs →  Obsolete statements of the screen flow logic →  Obsolete Processing of Step Loops 

LOOP - Steploop

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

LOOP [AT itab CURSOR top_line [INTO wa] [FROM n1] [TO n2]].
  ...
ENDLOOP.

Variants

1. LOOP.
2. LOOP AT itab CURSOR top_line [INTO wa] [FROM n1] [TO n2].

Effect

Definition of a loop in the screen flow logic. The loop sequentially processes the groups listed for the corresponding step loop by executing a loop pass for each group. The statement block between LOOP and ENDLOOP can contain the keywords FIELD, MODULE, and CHAIN (as well as the obsolete SELECT and VALUES) of the flow logic. Nesting of loops is not possible. Loops can either be executed with or without reference to an internal table.

If step loops are defined in a screen, a loop must be defined for each step loop both in the the PBO processing block as well as in the PAI processing block. The assignment of loops to step loops is derived from the alignment of the step loops on the screen - the lines are valuated with primary priority, and the columns with secondary priority.

System Fields

Within a loop pass, the system field sy-stepl contains the line number of the displayed group, counted from the uppermost, visible line. The system field sy-loopc contains the number of group lines displayed on a screen.

Variant 1

LOOP.
  ...

ENDLOOP.

Effect

If the AT itab addition is not specified, the contents of the screen fields belonging to the current group of the step loop are transported during a loop pass from (at event PBO) or to (at event PAI) data objects with the same name in the ABAP program.


Note

For step loop fields that are defined with reference to the ABAP Dictionary, the data objects with the same name in the ABAP program must be declared using TABLES, as is the case with normal dynpro fields. Otherwise, no data transport will take place.


Example

In the layout of the dynpro screen, there are two dynpro fields wa-col1 and wa-col2 that are grouped together to a group of a step loop. The screen flow logic contains the following statements:

PROCESS BEFORE OUTPUT.
  ...
  LOOP.
    MODULE tab_out.
  ENDLOOP.
  ...

PROCESS AFTER INPUT.
  ...
  LOOP.
    MODULE tab_in.
  ENDLOOP.
  ...

Loops are run on the step loop and, in the loops for PBO and PAI, the dialog modules tab_out and tab_in are called. The following program section shows how the respective ABAP program fills the step loop fields in the PBO module tab_out from an internal table itab. It also shows how, in the PAI module tab_in, it modifies the internal table in accordance with the user specifications in the step loop.

DATA: BEGIN OF wa, 
        col1 TYPE i, 
        col2 TYPE i, 
       END OF wa, 
       itab LIKE STANDARD TABLE OF wa. 

... 

MODULE tab_out OUTPUT. 
  IF itab IS INITIAL. 
    DO 40 TIMES. 
      wa-col1 = sy-index. 
      wa-col2 = sy-index ** 2. 
      APPEND wa TO itab. 
    ENDDO. 
  ENDIF. 
  READ TABLE itab INTO wa INDEX sy-stepl. 
ENDMODULE. 

... 

MODULE tab_in INPUT. 
  MODIFY itab FROM wa INDEX sy-stepl. 
ENDMODULE. 

Variant 2

LOOP AT itab CURSOR top_line [INTO wa] [FROM n1] [TO n2].
  ...

ENDLOOP.

Effect

If the addition AT itab is specified, an internal table itab of the corresponding ABAP program is sequentially processed parallel to the processing of the step loop. For each group of the step loop, a line in the internal table is processed. The internal table itab must be an index table.

A scroll bar will continue to be generated for the display of the corresponding step loop. This bar allows you to scroll between the lines of the internal table itab and to display the corresponding lines in the step loop. Each scrolling action triggers the event PAI. So that scrolling functions correctly, the addition AT itab must be specified both in the PBO as well as in the PAI processing block.

The additions CURSOR, INTO, TO, and FROM can only be specified in the PBO, not in the PAI processing block.

  • The addition CURSOR controls at which line of the internal table processing will begin at the time PBO - that is, the content of which line will be displayed first in the step loop. For top_line, you must have a global data object of the ABAP program with the type i specified. If the content of the top_line is less than 1 or the value of n1, it is implicitly set to 1 or to the value of n1. If it is larger than the number of lines in the internal table or than the value of n2, the step loop will not be displayed. For each PAI event, the top_line is set to the index of the first displayed table line.
  • With the addition INTO, you specify a work area wa to which the current line of the internal table is assigned at the time of PBO. If the addition wa is not specified, an internal table with a header line is used. This is then used implicitly instead of wa. The content of wa or of the header line is transported after the statement to the fields of the same name in the current group of the step loop. The work area wa must be a global data object of the ABAP program that matches the line type of the internal table. At the time of PAI, on the other hand, only the work area wa or the header line of the internal table is supplied through the contents of the step loop fields. The content of the internal table is not modified automatically.
  • With the additions FROM and TO, you can limit the internal table lines to be processed. Sequential processing of the table begins with the line whose index is contained in n1 and ends with the line whose index is contained in n2. If the additions are not specified, processing begins with the first and ends with the last line. For n1 and n2, global data objects of the ABAP program with the type i must be specified. The value of n2 must be larger than the value of n1 and it must be within the number of lines in the internal table. If the value of n1 is less than or equal to 0, it will be implicitly set to 1.


Example

In the layout of a dynpro screen, there are two screen fields wa-col1 and wa-col2 belonging to a group of a step loop. The screen (dynpro) flow logic contains the following statements:

PROCESS BEFORE OUTPUT. 
  ... 
  MODULE tab_init. 
  LOOP AT itab CURSOR top_line INTO wa. 
  ENDLOOP. 
  ... 

PROCESS AFTER INPUT. 
  ... 
  MODULE get_first_line. 
  LOOP AT itab. 
    MODULE tab_in. 
  ENDLOOP. 
  ...

Parallel loops are executed through the step loop and the internal itab table. At PBO, no dialog module is called in the loop. Instead, the module tab_init is called beforehand to edit the internal table itab. At PAI, the module tab_in is called in the loop to modify the internal table in accordance with the user specifications in the step loop. Beforehand, the module get_first_line is called in order to store the index of the first displayed table line in the help variable line. This is necessary since the content of top_line will be changed when the user scrolls further. The following program section shows the dialog modules of the corresponding ABAP program.

DATA: BEGIN OF wa, 
        col1 TYPE i, 
        col2 TYPE i, 
       END OF wa, 
       itab LIKE TABLE OF wa. 

DATA: top_line  TYPE i, 
      line TYPE i, 
      idx  TYPE i. 

... 

MODULE tab_init OUTPUT. 
  IF itab IS INITIAL. 
    DO 40 TIMES. 
      wa-col1 = sy-index. 
      wa-col2 = sy-index ** 2. 
      APPEND wa TO itab. 
    ENDDO. 
  ENDIF. 
ENDMODULE. 

... 

MODULE get_first_line INPUT. 
  line = top_line. 
ENDMODULE. 

MODULE tab_in INPUT. 
  idx = sy-stepl + line - 1. 
  MODIFY itab FROM wa INDEX idx. 
ENDMODULE.