The CHAIN statement provides a method for starting another run unit.
General Format
CHAIN program-name [ USING {parameter} ... ]
[ ON {EXCEPTION} statement ]
{OVERFLOW }
[ END-CHAIN ]
Syntax Rules
- program-name is a nonnumeric literal or an alphanumeric data item.
- parameter is any non-level 88 data item or a nonnumeric literal. No more than 50 parameters may be specified.
- statement is an imperative statement.
- If a CHAIN statement appears in a consecutive sequence of imperative statements within a sentence, it must be the last statement
in that sequence, unless the EXCEPTION phrase is specified.
General Rules
- The CHAIN statement causes the current run unit to terminate and initiates a new run unit. Executing a CHAIN statement has
the following effects:
- The current run unit is halted as if a STOP RUN statement were executed.
- The run unit specified by
program-name is initiated.
program-name is resolved into an executable program name using the same rules specified for the CALL statement.
- If the EXCEPTION phrase is used, then statement executes if the CHAIN statement is unable to load
program-name. This is usually caused by program-name being either absent or not readable by the runtime system. Certain types of errors
cannot be caught by the ON EXCEPTION phrase because of the nature of the CHAIN statement. If the EXCEPTION phrase is not present
when an error occurs, the runtime system prints a message and halts.
- If the USING phrase is specified, each parameter is transferred to the new run unit. Each parameter is mapped to the corresponding
CHAINING argument in the new run unit. See Procedure Division Format for a description of the CHAINING phrase.