SET
SET copies the contents of a source field to a destination field.
••••• SET
••• •••••••••••••••••••••• ••• = ••• ••••••••••••••••••••••
•••
(1)
(2) (3) (4) (5) (6) (7)
(7) Source occurrence (constant/index) | |
(4) Destination occ (constant/index) |
|
The contents of the source field are not modified. If the source and destination fields are of different types, conversion is performed automatically. The destination field must be either a field name or a modifiable predefined field. The source field can be a field name, a predefined field, or a constant. Constants are considered to be the same field type as the destination.
Specific information regarding the SET statement is provided in the following sections:
· When the SET Destination is Alpha
· When the SET Destination is a Number
· When the SET Destination is a Date
· When the SET Destination is a Logic Field
The destination field must be either a field name or a modifiable predefined field.
For an alpha destination, if the source field is null, the intermediate alpha form is set to blank. If the converted value is too large to fit in the destination, it is truncated.
For a numeric destination, if the destination field is not large enough to hold the integer part of the source field value, a numeric overflow condition results. Overflow processing is dependent on the use of OVERFLOW statements within the event point containing the SET statement. If the source field is null or blank, the destination field is set to its null value. In addition, a valid source field must contain only digits, an optional decimal point, an optional leading or trailing sign, and optional leading and/or trailing spaces.
For a date destination, unless the source field is null, it must contain exactly 16 decimal digits. A date constant must be exactly 16 characters in length, without leading or embedded blanks, and with trailing blanks. Only those characters of the date constant that are within the range of the date parts of the destination date field must be valid date values.
For numeric and date destinations, a non-recoverable error occurs at runtime if a restriction (as described in the appropriate section) is not complied with.
The following subroutine is an example of the use of the SET statement. Note that some fields are alpha, some are numeric, some are dates, and some are constants. The example includes both alpha and numeric constants (since constants are deemed to be the same field type as the destination field).
LABEL DEFAULT
MTDPOST
SET TAR
MTDPOST FULL = TAR
ADJUST2 FULL
SET TAR
MTDPOST AMOUNT = TAR
ADJUST2 AMOUNT
COMPUTE TAR
MTDPOST AMOUNT * -1
IF TAR
PARAM POST TO GL EQ 1
T IF TAR
MTDPOST AMOUNT GE 0
TT SET TGL POST
ADJUSTMENT = 0
TF SET TGL POST
ADJUSTMENT = 1
SET TAR
MTDPOST TRX DATE = TAR
ADJUST2 TRX DATE
SET TAR
MTDPOST APPLY TO = TAR
ADJUST2 APPLY TO
RETURN