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 parenthesis of an expression NEW line_type( ... ), with one exception. Here, line_type is the row type of the internal table and a corresponding row is constructed.

The exception to this rule are tabular row types. The syntax in the inner parenthesis does not allow further parentheses to be nested directly.

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 the inner parentheses applies for reasons of legibility (human and machine) and is not a functional restriction. The expression VALUE line_type( ... ) can be specified 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 requirement with 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.

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

Effects when using the left side of an assignment in specified rows.

  • In the construction of itab1, the left side is used after BASE. 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 by LINES OF itab2 and 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 using BASE. These rows are then appended again using LINES OF, before the two single rows are appended.
  • In the construction of itab4, the left side is saved in the auxiliary variable x before it is initialized. It is then used in LINES OF. The result is the same as when the left side is used after BASE.
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( itab ). 

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