ABAP - Keyword Documentation →  ABAP - Reference →  Predefined Types, Data Objects, Functions, and Constructors → 

Constructor Operators for Constructor Expressions

Syntax

... NEW| VALUE| CONV| CORRESPONDING| CAST| REF| EXACT| REDUCE| FILTER| COND|SWITCH
     type( ... ) ...

Effect

A constructor expression consists of the following:

Each constructor expression creates a result whose data type is determined using the specified type. The parameters specified in parentheses are used to pass input values. The following constructor operators exist:

A constructor expression can be specified in general expression positions and functional positions with an appropriate operand type. The result is used here as an operand. In a calculation expression or relational expression, the specified type type is incorporated into the calculation type or comparison type. An expression with the operator VALUE that is not used to create an initial value cannot be specified directly in an arithmetic expression. This is because it never matches the operand type here. Expressions with the operators NEW and CAST can be positioned directly before the object component selector -> and can occur in chainings.

Data types and classes that are visible and usable in the current operand position can be specified for type. This includes the built-in ABAP types, types defined using TYPES, types from ABAP Dictionary, and both local and global classes. If the data type required in an operand position is unique and fully recognizable, the # character can be used instead of an explicitly specified type type and the operand type is used. If the operand type is not unique and is not known completely, a type inference is performed to determine a data type. This is described in each constructor expression.

LET expressions can be used to define local helper fields in all suitable constructor expressions.

Notes

Example

Fills an internal table itab with the value operator VALUE. The data type is inferred from the left side of the assignment.

DATA itab TYPE TABLE OF i WITH EMPTY KEY.

itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).