ABAP - Keyword Documentation →  ABAP - Programming Language →  Creating Objects and Values →  VALUE, Value Operator →  VALUE, Internal Tables → 
Mail Feedback

VALUE, line_spec

Syntax

... line
  | {LINES OF itab [FROM idx1] [TO idx2] [STEP n] [USING KEY keyname]} ...


Alternatives:

1. ... line

2. ... LINES OF jtab [FROM idx1] [TO idx2] [STEP n] [USING KEY keyname]

Effect

Specification of one or more lines to be inserted when constructing an internal table with the value operator VALUE.

Hint

If lines from the target table or the entire target table are used in line_spec in an assignment of a constructor expression using the value operator VALUE to an internal table, these lines are deleted or overwritten with a start value before both variants of line_spec are evaluated. The target table must therefore be saved in an auxiliary variable first, for which a LET expression can be used.

Alternative 1  

... line




Effect

Specification of a line. For line, the exact same specifications can be made as in the parentheses of an expression NEW line_type( ... ), where line_type is the line type of the internal table and a corresponding line is constructed. The following special features apply here:

Short Form for Structured Line Types  

If the line type of the internal table is a structured type, the following short form can be used:

VALUE dtype|#( [let_exp]
               [BASE itab]
               col1 = dobj11 ... ( col2 = dobj12 col3 = dobj13 ... )
                                 ( col2 = dobj22 col3 = dobj23 ... )
                                 ...
               col1 = dobj31 col2 = dobj32 ... ( col3 = dobj33 ... )
                                               ( col3 = dobj43 ... )
               ... ).

This has the same semantics as the following:

VALUE dtype|#( [let_exp]
               [BASE itab]
               ( col1 = dobj11 ... col2 = dobj12 col3 = dobj13 ... )
               ( col1 = dobj11 ... col2 = dobj22 col3 = dobj23 ... )
               ...
               ( col1 = dobj31 col2 = dobj32 ... col3 = dobj33 ... )
               ( col1 = dobj31 col2 = dobj32 ... col3 = dobj43 ... )
               ... ).

Values can be assigned to individual structure components outside of the inner parentheses. An assignment of this type applies to all subsequent inner parentheses until the next assignment is made to the corresponding component. Assignments outside of the inner parentheses must be followed by at least one inner parenthesis. Since a component cannot be assigned a value more than once in the construction of a structure, a component that has been assigned a value outside of the inner parentheses can no longer be listed in an inner parenthesis. A component can be specified again outside the inner parentheses and any components previously specified in an inner parenthesis can also be listed outside the parenthesis.

Hints



Example

Construction of a ranges table and filling it with four lines while using the short form for structured line 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 )  ).

Alternative 2  

... LINES OF jtab [FROM idx1] [TO idx2] [STEP n] [USING KEY keyname]




Effect

Specification of multiple lines. The lines are taken from the internal table jtab and inserted into the target table as a block. The same applies to jtab and the additions FROM, TO, STEP and USING KEY as to the addition LINES OF of the statement INSERT and the block is inserted in accordance with these rules. jtab is a functional operand position.

Hints



Example

Construction of an internal table with an elementary line type. jtab is filled with three lines and itab with six lines. The first line inserted in itab is initial and the last three lines are taken from the table jtab filled previously.

TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY.

FINAL(jtab) = VALUE t_itab( ( 10 ) ( 20 ) ( 30 ) ).

FINAL(itab) = VALUE t_itab( ( ) ( 1 ) ( 2 ) ( LINES OF jtab ) ).

cl_demo_output=>display( itab ).

Example

Construction of an internal table with an elementary line type. jtab is filled with ten lines and itab with six lines. The first line inserted in itab is initial and the last three lines are taken from the table jtab filled previously. The additions FROM and STEP define the step size for processing the table jtab: Every second line starting at the sixth line is read.

TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY.

FINAL(jtab) = VALUE t_itab( FOR i = 10 THEN i + 10
  UNTIL i > 100 ( i ) ).

FINAL(itab) = VALUE t_itab( ( ) ( 20 ) ( 40 )
  ( LINES OF jtab FROM 6 STEP 2 ) ).