SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation →
ABAP − Reference →
Creating Objects and Values →
VALUE - Value Operator
Syntax
... VALUE type( ... ) ...
Effect
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.
The # character as a symbol for the
operand type. Can be specified
only if the data type required in an operand position is unique and fully identifiable. An exception to this rule is VALUE #( table_exp ).
The operator
- creates initial values for any non-generic data types
- constructs the content of
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.
If a single table expression is specified as a
parameter, VALUE does not construct a value and controls the category of its result instead, as described in the related section.
Notes
- Elementary data types and reference types cannot be specified explicitly for VALUE
using pass by value. 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 using pass by value are not possible. 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.
- From a technical perspective, the value operator VALUE creates a temporary
data object whose data type is determined by the specified type and whose content is determined by the
passed parameters. This data object is used as the operand of a statement and then deleted. It is deleted
when the current statements is closed or after the analysis of a relational expression once the logical value has been determined.
Example
Constructs the values of a structure of type T100 declared inline.
DATA(wa) = VALUE t100( sprsl = 'E'
arbgb = 'DEMO'
msgnr = '111'
text = '...' ).
Continue
VALUE - Initial Value for All Types
VALUE - Structures
VALUE - Internal Tables