The SET statement transfers data from a source to a target. The SET statement does not modify the value of the source and the original data remains in the source after it is used to set the target.
There are six formats that you can use for the SET statement, depending on the type of source value used.
The SET Numeric Field statement has the following format:
{alphanumeric_expression}
SET numeric_field = {numeric_expression }
{NULL }
Moves a value to an elementary numeric field according to the following rules:
The SET Alpha Field statement has the following format:
{alphanumeric_expression }
{numeric_field }
SET alphanumeric_field ={numeric_literal }
{group }
{NULL }
Moves a value to an elementary alphanumeric field according to the following rules:
If both the source and target are alphanumeric fields, the value is moved as follows:
If the source is a non‑alpha group, it is treated as an alphanumeric field whose length is the same as the size of the group. However, subordinate numeric fields are not converted. The hexadecimal values are simply moved.
You cannot specify restricted groups. For more information about non‑alpha groups, see the "Procedure Definition Language Concepts and Language Elements" chapter.
PDF can convert low values moved to an alphanumeric panel field by using the $LOW function (or some other means) to special characters. See the Creating Panel Definitions Guide for more information. Fields filled with low values are considered empty. The next TRANSMIT fills this empty field with the output fill character when it is next displayed.
You cannot move a value directly from a date type source to an alphanumeric target. First, convert the date using an explicit $DATE or $STRING function.
When a value from a non‑date numeric source is moved to an alphanumeric target, the data in the numeric source is first converted to alphanumeric by applying the $STRING function (see the "Symbolic Debugger Commands" chapter).
If you do not want to use the $STRING rules, you can specify a $EDIT function in a numeric expression as the source. Use the default PIC or specify one of the other edit patterns (see the "Symbolic Debugger Commands" chapter).
If the conversion results in a value that is longer than the target field after any leading blanks were removed, digits are truncated from the right to fit. For example, if NUM is a three‑digit numeric field and STR is a two‑character alphanumeric field, the expression results in STR having a value of '12' if NUM has a value of 123. If, however, NUM has a value of 12 or 1, STR has a value of '12' or '1', respectively.
SET STR = NUM
You cannot move an arithmetic expression or numeric function to an alphanumeric target without first moving it to a numeric target.
If the source is the keyword NULL or evaluates to the null value, the target field must be nullable. It is set to the null value.
The SET Group statement has the following format:
SET group1 = group2 {BY NAME } [USING {$EDIT } [RULES]
{BY POSITION} [ {$STRING} ]
Moves data from one group to another. The following rules apply:
When values are moved from a non‑alpha group to an alpha target, the default is to convert numeric data to alphanumeric by applying a $STRING function. You can specify to use a $EDIT function instead. See the options USING $EDIT RULES and USING $STRING RULES that follow.
Moves the value from each field in the source group to an identically named field in the target group if one exists. OCCURs in the respective groups (if any) must be compatible. Only values from fields that have the same names are subordinate to the respective groups and are elementary are moved. Redefinitions in the sending group are not eligible sources; however, redefinitions in the receiving group are eligible targets. A compile‑time error message is issued if the number of occurrences does not match. A runtime error occurs if the number of occurs depending on or parameter field occurrences does not match.
For example, if the source group is:
Level Field Occur 1 A 2 B 2 2 C 2
and the target group is:
Level Field Occur 1 X 2 Y 2 3 B 3 C
then the statement,
SET X = A BY NAME
moves the values of the Bs and Cs in the source group to fields with corresponding names in the target group.
Moves the value of the first elementary field in the source group item to the first elementary field in the target group item, regardless of its name; the second to the second, and so on. The group structures must be compatible as follows:
You can test structures for compatibility by using the following steps:
Note: No field values are moved unless the structures that remain after this test is applied are compatible.
In a group move only, converts numeric fields to alphanumeric by applying a $EDIT function with an edit pattern of PIC 9(n), where n is the number of integer places in the field. The default is to use a $STRING conversion.
In a group move only, performs numeric conversion using the $STRING rules.
The statement SET Flag has the following format:
SET flag = {TRUE }
{FALSE }
The item on the left side of the equal sign is a flag. The value on the right side of the equal sign must be the reserved word TRUE or FALSE.
The statement SET Condition has the following format:
SET condition_name = TRUE
Sets a condition name to the TRUE value.
The statement SET Function has the following format:
{numeric_expression }
SET pseudo_function = {alphanumeric_literal}
{alphanumeric_field }
You can only set the $RETURN‑CODE function to a numeric_expression.
Examples
SET Numeric Field
SET CHARGE = QUANTITY_ORDERED * UNIT_PRICE SET AMOUNT_RQRD = CURRENT_AMOUNT SET PAY_AMT_NUMERIC = $NUMBER (PAY_AMT) SET Z = ((Y + Z)*W)/(A ‑ B) SET L = A + ($REMAINDER(M,N) ‑ $ROUND(J,1))/3.6
SET Alpha Field
SET ALPHA = $STRING (X,Y,Z)
SET Flag
SET EMP_NOT_VALID = FALSE
SET Condition
SET RED = TRUE
SET Function
SET $FIXED‑MASK = '%'
Also see the MOVE statement examples in this chapter for examples that correspond to SET BY POSITION, SET BY NAME, and alpha group moves.
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|