Professional Documents
Culture Documents
https://help.sap.com/doc/abapdocu_751_index_htm/7.51/en-us/abenvalue_constructor_params_itab.htm
SAP NetWeaver AS ABAP Release 751, ©Copyright 2017 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Creating Objects and Values → VALUE - Value Operator →
itab1 = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).
itab2 = VALUE #( ( itab1 )
( VALUE t_itab1( ( 4 ) ( 5 ) ( 6 ) ) ) ).
Examples
See also the examples for the instance operator NEW.
Executable Examples
VALUE Operator for Internal Tables
VALUE Operator with LET for Internal Tables
Addition 1
... BASE itab
Effect
An addition, BASE, followed by an internal table, itab, can be specified in front of the lines that you want to insert. This is
a functional operand position. The row type of itab must be convertible to the row type of the return value. If BASE is specified,
the content of itab is assigned to the return value before the individual rows are inserted. If the character # is specified for the
type of the return value and the type cannot be determined from the operand position of the constructor expression, the type
of itab is used for this expression (if identifiable).
Notes
If the addition BASE is not specified, the content of tables can only be reconstructed using the value operator and no
new content can be added. If the same table is specified after BASE to which the constructor expression is assigned,
further rows can be inserted in this table.
If the target table is specified as itab after BASE in an assignment to an existing internal table, no assignment takes
place before line_spec is evaluated, and the target table just keeps its value instead.
Example
Uses BASE. The table type of base1 or base2 is applied in the construction of tab1 and tab2. This is not possible in the
construction of tab3 since the row type of base2 is not structured and hence not suitable for specifying individual components
in the parentheses that follow. The type itab2 is specified explicitly for tab3. This is possible since the row type of base2 can
be converted into this row type. Sorted tables are constructed, which means that the rows in the results are also sorted.
TYPES:
itab1 TYPE SORTED TABLE OF string WITH UNIQUE KEY table_line,
BEGIN OF struct,
col1 TYPE c LENGTH 2,
col2 TYPE c LENGTH 2,
col3 TYPE c LENGTH 2,
END OF struct,
itab2 TYPE SORTED TABLE OF struct WITH UNIQUE KEY col1 col2 col3.
DATA(tab2) = VALUE #(
BASE base2
( col1 = 'A1' col2 = 'B1' col3 = 'C1' )
( col1 = 'A2' col2 = 'B2' col3 = 'C2' ) ).
cl_demo_output=>write( tab1 ).
cl_demo_output=>write( tab2 ).
cl_demo_output=>display( tab3 ).
Example
Uses BASE to append rows to existing rows in an internal table.
TYPES itab TYPE TABLE OF string WITH EMPTY KEY.
DATA(itab) =
VALUE itab(
( `a` ) ( `b` ) ( `c` ) ).
...
itab =
VALUE #(
BASE itab
( `d` ) ( `e` ) ( `f` ) ).
cl_demo_output=>display( itab ).
Example
Uses BASE to append rows to an internal table in a loop. After the output, it possible to see how the same function can be
applied using an iteration expression with FOR.
DATA itab TYPE TABLE OF i WITH EMPTY KEY.
DO 10 TIMES.
itab = VALUE #( BASE itab ( ipow( base = sy-index exp = 2 ) ) ).
ENDDO.
cl_demo_output=>display( itab ).
cl_demo_output=>display(
VALUE t_itab( FOR i = 1 UNTIL i > 10
( ipow( base = i exp = 2 ) ) ) ).
Executable Examples
Examples of Table Comprehensions
Continue
VALUE - line_spec
VALUE - Operator for Internal Tables
VALUE - Operator with LET for Internal Tables