Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Program Flow Logic →  Iteration Expressions →  FOR - Iteration Expressions →  Examples of Iteration Expressions 

Creating Tables Using FOR and VALUE

The example demonstrates conditional iterations with the operator VALUE.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    TYPES:
      BEGIN OF line,
        col1 TYPE i,
        col2 TYPE i,
        col3 TYPE i,
      END OF line,
      itab TYPE STANDARD TABLE OF line WITH EMPTY KEY.

    cl_demo_output=>write(
        VALUE itab(
          FOR j = 11 THEN j + 10 WHILE j < 40
          ( col1 = j col2 = j + 1 col3 = j + 2  ) ) ).

    cl_demo_output=>write(
        VALUE itab(
          FOR j = 31 THEN j - 10 UNTIL j < 10
          ( col1 = j col2 = j + 1 col3 = j + 2  ) ) ).

    cl_demo_output=>display( ).

Description

This example demonstrates the construction of internal tables using condition iterations with a constructor expression and the corresponding variant of the value operator VALUE. Two internal tables with different iterations are created and the output produced directly.