ABAP Keyword Documentation → ABAP − Reference → Creating Objects and Values → VALUE - Value Operator → VALUE - Internal Tables
VALUE - Operator for Internal Tables
This example demonstrates the value operator VALUE for internal tables.
Other versions:
7.31 | 7.40 | 7.54
Source Code
TYPES itab TYPE STANDARD TABLE OF i WITH EMPTY KEY.
DATA(itab) = VALUE itab( ( 1 ) ( 2 ) ( 3 ) ).
DATA(itab1) = itab.
itab1 = VALUE #( BASE itab1
( 4 )
( 5 ) ).
cl_demo_output=>write( itab1 ).
DATA(itab2) = itab.
itab2 = VALUE #( ( LINES OF itab2 )
( 4 )
( 5 ) ).
cl_demo_output=>write( itab2 ).
DATA(itab3) = itab.
itab3 = VALUE #( BASE itab3
( LINES OF itab3 )
( 4 )
( 5 ) ).
cl_demo_output=>write( itab3 ).
DATA(itab4) = itab.
itab4 = VALUE #( LET x = itab4 IN
( LINES OF x )
( 4 )
( 5 ) ).
cl_demo_output=>write( itab4 ).
cl_demo_output=>display( ).
Description
The example shows various effects when using the left side of an assignment in specified rows of the operator VALUE in the construction of internal tables.
- In the construction of
itab1, the left side is used afterBASE. Here, the original three rows are passed as a start value before the specified rows are evaluated. Two single rows are then appended to this start value.
- In the construction of
itab2, the left side is initialized before the specified rows are evaluated. This is why no rows are inserted byLINES OF itab2and the table contains only two single rows.
- In the construction of
itab3, the left side is given its original three rows as a start row usingBASE. These rows are then appended again usingLINES OF, before the two single rows are appended.
- In the construction of
itab4, the left side is saved in the helper variablexbefore it is initialized. It is then used inLINES OF. The result is the same as when the left side is used afterBASE.