ARTICLE
VALUE - Internal Tables
Syntax
... VALUE dtype|#( ( ... ) ( ... ) ... ) ...
Effect
If dtype is a tabular data type or # represents a type
like this, further parentheses can be added at the top level in the
parentheses after dtype . Each inner parenthesis inserts a row
into the tabular return value. The same items can be specified in every
inner parenthesis and the same rules apply as in the
construction of table rows using
the instance operator NEW .
In particular, the short form for structured types described there can
be used.
Note
Internal table rows are constructed in accordance with the rules for the
instance operator NEW ,
since new table rows are created here as well.
Example
Constructs an internal table with an elementary row type and fills it
with three rows. The first row inserted is initial.
TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY.
DATA itab TYPE t_itab.
itab = VALUE #( ( ) ( 1 ) ( 2 ) ).
Example
Constructs an internal table with an elementary row type of type
string and fills it with three rows. The result is a table that is
given the previous day, current day, and next day formatted for the cur
rent language environment.
TYPES t_date_tab TYPE TABLE OF string WITH EMPTY KEY.
DATA date_tab TYPE t_date_tab.
date_tab = VALUE #(
( |{ CONV d( sy-datlo - 1 ) DATE = ENVIRONMENT }| )
( |{ sy-datlo DATE = ENVIRONMENT }| )
( |{ CONV d( sy-datlo + 1 ) DATE = ENVIRONMENT }| ) ).
Example
Constructs an internal table with a structured row type and fills it
with two rows. The structures are filled with values component by
component.
TYPES: BEGIN OF t_struct,
col1 TYPE i,
col2 TYPE i,
END OF t_struct,
t_itab TYPE TABLE OF t_struct WITH EMPTY KEY.
DATA itab TYPE t_itab.
itab = VALUE #( ( col1 = 1 col2 = 2 )
( col1 = 3 col2 = 4 ) ).
Example
Constructs a ranges table and fills it
with four rows while using the short
form for structured row types.
DATA itab TYPE RANGE OF i.
itab = VALUE #( sign = 'I' option = 'BT' ( low = 1 high = 10 )
( low = 21 high = 30 )
( low = 41 high = 50 )
option = 'GE' ( low = 61 ) ).
Example
Constructs an internal table with a tabular row type and fills it with
two rows. The first row is assigned a table that is already filled. The
second row is constructed using VALUE .
TYPES: t_itab1 TYPE TABLE OF i WITH EMPTY KEY,
t_itab2 TYPE TABLE OF t_itab1 WITH EMPTY KEY.
DATA itab1 TYPE t_itab1.
DATA itab2 TYPE t_itab2.
itab1 = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).
itab2 = VALUE #( ( itab1 )
( VALUE t_itab1( ( 4 ) ( 5 ) ( 6 ) ) ) ).
Example
See also the examples for the instance operator
NEW .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved