SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation →
ABAP - Reference →
Creating Objects and Values →
VALUE - Value Operator
... VALUE type( ... ) ...
A constructor expression with the value operator
VALUE creates a result of a data type specified using type. The following can be specified for type:
- A non-generic data type dtype.
- Exceptions to this rule are:
- When an initial value VALUE #(
) is passed to a generically typed formal parameter, the type is derived from the generic type.
- creates initial values for any non-generic data types
- constructs the content of
- controls the type of the result of table expressions and so enables a default value to be specified for unfound rows
The content of the result is determined by the parameters specified in parentheses. The syntax used
in pass by parameter depends on the type used when the value was constructed. There are specialized categories of pass by parameter for each possible type.
- Pass by parameter when constructing values:
- If a single table expression is specified as a parameter, VALUE does not construct a value. Instead it controls the type of the
In an assignment of a constructor expression to a
data object using VALUE, the data object is used directly. It is overwritten in full with an initial value or start value before being assigned the values specified in the parentheses.
- Elementary data types and reference types cannot be specified explicitly with VALUE
for constructing values, except when an initial value is created. Unlike when using the instance operator
NEW, the correct
result can be achieved by using direct assignments. For this reason, it is not necessary to specify
unnamed arguments as single values when using NEW (and also not allowed). The use of VALUE to control
table expressions is not affected by this, since any valid data type can be specified here.
- Arithmetic calculations with the results of VALUE for constructing values
are not possible (except when creating an initial value). This means that constructor expressions of this type cannot be specified directly in the operand positions of
arithmetic expressions. Constructor expressions using VALUE used to control
table expressions are not affected by this, if the table expressions can be used for calculations using valid results.
- The conversion operator CO
closes the gap where no elementary data objects can be constructed in operand positions using VALUE.
- If a constructor expression with VALUE is not used as the source of an
assignment to a data object, the value operator VALUE creates a new temporary
data object whose data type is determined by the specified type and whose content is determined by the
parameters passed. This data object is used as the operand of a statement and then deleted. It is deleted
when the current statement is closed or after the analysis of a relational expression once the truth value is determined.
- In assignments to a data object, the target variable is used directly and no temporary data object
is created. This variable is initialized or overwritten in full before the assignment of the values
specified in the parentheses. Its original value, however, is still available in an optional
LET expression. This is the difference between VALUE
and the instance operator NEW.
Constructs the values of a structure of type TB declared inland.
DATA(WA) = VALUE td( spryly = 'ER'
VALUE - Initial Value for All Types
VALUE - Structures
VALUE - Internal Tables
AR = 'DEMO'
ms = '111'
text = '...' ).