Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Creating Objects and Values →  VALUE - Value Operator →  VALUE - Internal Tables 

VALUE - line_spec

Other versions: 7.31 | 7.40 | 7.54

Syntax


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

Alternatives

1. ... line
2. ... LINES OF jtab [FROM idx1] [TO idx2] [USING KEY keyname]

Effect

Specifies one or more rows to be inserted when constructing an internal table with the value operator VALUE.


Note

If rows 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 rows are deleted or overwritten by a start value before both variants of line_spec are evaluated. The target table must therefore be saved in an auxiliary variable first. A LET expression can be used to do this.

Alternative 1

... line

Effect

Specifies a row. line can be specified in exactly the same way as in the parentheses of an expression NEW line_type( ... ). Here, line_type is the row type of the internal table and a corresponding row is constructed. The following special features apply here:

  • If a data object is specified for line, this object must be compatible with the row type.
  • If an expression (built-in function, functional method, calculation expression, constructor expression, or table expression) is specified for line, the result of the expression must be convertible to the row type.
  • The syntax does not permit further parentheses for constructing tabular row types to be nested directly in line.

Short Form for Structured Row Types

If the row 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 following inner parentheses until the next assignment is made to the component in question. Assignments outside of the inner parentheses must be followed by at least one inner parenthesis. A component cannot be assigned a value more than once in the construction of a structure, which means that a component assigned a value outside of the inner parentheses can no longer be specified 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.


Notes

  • The restriction that the content of tabular row types cannot be constructed directly in line applies for reasons of legibility (for humans and for machines) and is not a functional restriction. The expression VALUE line_type( ... ) can be specified for line to construct the content of a tabular row, where line_type is the tabular row type.

  • Specifying CONV line_type( ... ) for the inserted values is also a way of meeting the compatibility requirements made by the row type.

  • The short form for structured row types enables columns of internal tables that are to be given an identical value in blocks to be filled more easily.

  • As in VALUE, the table rows are constructed in accordance with the rules for the instance operator NEW, since new table rows are created here too and the restriction for VALUE dictating that no values of elementary data objects can be constructed cannot be applied.

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 )  ). 

Alternative 2

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

Effect

Specifies multiple rows. The rows 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, 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.


Notes

  • The rows from jtab are inserted into the target table using the table key only, which means that jtab must be compatible with the target type.

  • If there is a conflict with an existing unique table key, a non-handleable exception is always raised when inserting multiple rows from an internal table using the statement INSERT.

  • When standard tables are created, the rows of the table jtab are appended to the target table in the same way as with the statement APPEND LINES OF.

Example

Constructs an internal table with an elementary row type. jtab is filled with three rows and itab with six rows. The first row inserted in itab is initial and the last three rows are taken from the table jtab filled previously.

TYPES t_itab TYPE TABLE OF i WITH EMPTY KEY. 

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

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

cl_demo_output=>display( itab ).