The command’s VARIABLE-NAME operand refers to the variable to which new contents are to be assigned. This variable can be a simple or a complex variable. Unless otherwise specified, for each assignment the old variable contents are first deleted and then the new contents are assigned.
Specifying variable names directly
The input destination can be specified in the VARIABLE-NAME operand directly as the variable name of a simple variable or the variable name of a structure.
If NAME designates a simple variable, this variable must be overwritable. If the specified variable is not a variable element and has not yet been declared, it is declared implicitly with SCOPE = *CURRENT and the data type ANY, provided that the implicit declaration of variables is allowed.
If NAME designates a variable element that does not yet exist, it is again declared implicitly, provided that the superordinate complex variable exists and can be extended.
A number of variable names (up to 2000) can be specified in the form of a list: they should then be enclosed in parentheses: (varname1, varname2, ...). The rules described above apply to each of these variable names.
When variables are specified in this type of list, it must be possible to assign a value to each of these variables. If the input is shorter than this list (i.e. if values cannot be assigned to all the variables), error handling is activated.
Creating variables implicitly
Variables can be created implicitly in the VARIABLE-NAME operand of the READ-VARIABLE command, depending on the input (VARIABLE-NAME = *BY-INPUT(..)). This entry requires that variables be read in the format that is generated by the SHOW-VARIABLE command with its operands when variables are output. This means that a variable name and variable value are read in.
If simple variables that already exist are read in, they are assigned a value.
If the simple variables are variable elements, the following distinctions must be made:
If a list element is read in, the command is rejected.
If a structure element is read in whose superordinate structure has not yet been declared, the structure is created implicitly with SCOPE = *CURRENT.
If a static structure is read in that does not yet exist in the procedure, it is recreated, not as a static structure, but as a dynamic structure.
The following applies to reading in both simple and complex variables: if a variable is read in that is not yet initialized (contents *NO-INIT) (i.e. that has not yet been assigned a value), the corresponding variable in the procedure is deleted implicitly (implicit FREE-VARIABLE).
Reading into a list variable
The name of a list variable can be specified in the VARIABLE-NAME operand of the READ-VARIABLE command. If a list with this name does not yet exist in the procedure, a list is created implicitly (if allowed) with SCOPE = *CURRENT and the data type TYPE = *STRING.
The list can be overwritten (WRITE-MODE = *REPLACE) or extended (WRITE-MODE = *EXTEND).
“Overwrite” means that the old list contents are first deleted. The values read in are then assigned to the list elements one after the other, beginning with the list header. “Extend” means that the old list contents are retained. With each assignment, the list is extended by one element, i.e. an element is appended to the end of the list and is then assigned the value read in.