Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Internal Tables →  Expressions and Functions for Internal Tables →  table_exp - Table Expressions →  table_exp - Writer Positions 

Table Expressions, Writer Positions

This example demonstrates table expressions in writer positions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA(itab) = VALUE itab(
                   ( col1 = 3 )
                   ( col1 = 5 )
                   ( col1 = 7 ) ).

    DATA(out) = cl_demo_output=>new(
      )->begin_section( `Before`
      )->write( itab ).

    DO lines( itab ) TIMES.
      change_component( EXPORTING p1 = itab[ sy-index ]-col1
                        IMPORTING p2 = itab[ sy-index ]-col2 ).
    ENDDO.

    out->next_section( `After change_component`
      )->write( itab ).

    DO lines( itab ) TIMES.
      change_line( CHANGING p = itab[ sy-index ] ).
    ENDDO.

    out->next_section( `After change_line`
      )->write( itab
      )->display( ).

Description

In a DO loop, the content of an internal table

  • is passed component by component to an IMPORTING parameter and EXPORTING parameter of a method using two table expressions. This modifies one column of the current row.
  • is passed row by row to a CHANGING parameter of a method using one table expression. This modifies one column of the table row.

The second method is quicker, of course, since only one read is performed on the internal table instead of two.