VALUE - Value Operator
7.31 | 7.40 | 7.54
... 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
- A non-generic data type
#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. The following exceptions apply:
- When an initial value VALUE #( ) is passed to a generically typed formal parameter, the type is derived from the generic type.
- When used for a single table expression
VALUE #( table_expo ).
The operator does the following:
- It creates initial values for any non-generic data types.
- It constructs the content of the following:
- Structured types
- Table types
- It controls the type of the result of table expressions and so enables a default value to be specified for any rows not found.
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,
VALUEdoes not construct a value and controls the type of the result instead.
In assignments of constructor expressions to a data
VALUE, the data object is used directly. It is overwritten in full by an initial value or start value before being assigned the values specified in the parentheses.
- The value operator
VALUEcan also be used to construct the content of existing complex data objects (structures and internal tables). This goes beyond what is possible using the
- The value operator
VALUEuses mainly the same syntax as in the instance operator
NEWto create values.
- When using the operator
VALUEto construct values, elementary data types and reference types cannot be specified explicitly, 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
VALUEto control table expressions is not affected by this, since any valid data type can be specified here.
- Arithmetic calculations with the results of
VALUEfor 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. Any constructor expressions with
VALUEused to control table expressions are not affected by this (if the table expressions can be used for calculations using valid results).
- The conversion operator
CONVcloses the gap where no elementary data objects can be constructed in operand positions using
- If a constructor expression with
VALUEis not used as the source of an assignment to a data object, the value operator
VALUEcreates 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 either when the current statement is closed or when a relational expression is evaluated after 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
LETexpression. This is the difference between
VALUEand the instance operator
Constructs the values of a structure of type T100 declared inline.
DATA(wa) = VALUE t100( sprsl = 'E' arbgb = 'DEMO' msgnr = '111' text = '...' ).