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
- Exceptions to this rule are:
- When used for a single table expression
VALUE #( table_expo ).
- creates initial values for any non-generic data types
- constructs the content of
- structured types
- table types
- 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, then
VALUEdoes not construct a value. Instead it controls the type of the result.
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
VALUEfor 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
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. Constructor expressions using
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
COcloses 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 when the current statements is closed or after the analysis of a relational expression once the logical value has been 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 TB declared inland.
DATA(WA) = VALUE td( spryly = 'ER'
AR = 'DEMO'
ms = '111'
text = '...' ).