Terminate procedure run (return to caller)
Component: | SYSFILE |
Functional area: | Procedures |
Domain: | PROCEDURE |
Privileges: | STD-PROCESSING |
Function
The EXIT-PROCEDURE command is an SDF-P control flow command. It terminates procedure execution and returns control to the caller, i.e. the procedure level from which the call was made. If EXIT-PROCEDURE terminates the last procedure, control returns to the primary command input (corresponding to procedure level 0):
In interactive mode, command input (SYSCMD) is assigned primarily to the terminal, in batch mode to the ENTER file.
The system files (including TASKLIB) receive the assignment in force at the interrupt point. A file that was assigned by means of ASSIGN-SYSLST in the procedure is closed by EXIT-PROCEDURE.
The ERROR operand can be used to pass a command return code to the caller. This code can be evaluated with SDF-P facilities (see IF-BLOCK-ERROR command).
The RESUME-PROGRAM operand can be used to specify that a loaded program may be continued after termination of the procedure. This function corresponds to the ENDP-RESUME command.
If an EOF condition is encountered (physical end of the procedure file is reached during command processing), the procedure is terminated as if an EXIT-PROCEDURE command had been issued. The caller receives a return code corresponding to the current error status on termination.
The effect of an EXIT-PROCEDURE command in ESCAPE mode is described under the HOLD-PROCEDURE command.
If errors occur in an S procedure, the EXIT-PROCEDURE command is not recognized.
Format
EXIT-PROCEDURE |
Operands
ERROR =
This specifies which information on procedure execution the caller is to receive.
ERROR = *NO(...)
The caller receives the return code of class “NO-ERROR”. Additional information can be passed via the SUBCODE2 and MAINCODE operands:
SUBCODE2 = 0 / <integer 0..255>
This passes additional information in SUBCODE2. The default value is zero, i.e. there is no additional information.
MAINCODE = CMD0001 / <alphanum-name 7..7>
This passes a message code. The caller can request an explanation of the message by means of the HELP-MSG-INFORMATION command.
The default value is CMD0001, i.e. procedure terminated without errors.
ERROR = *YES(...)
The caller receives a return code indicating an error. The operands SUBCODE1, SUBCODE2, and MAINCODE can be used to identify the error class and any additional information:
SUBCODE1 = 64 / <integer 0..255>
This indicates the error class of the relevant error.
SUBCODE2 = 0 / <integer 0..255>
This passes additional information in SUBCODE2. The default value is zero, i.e. there is no additional information.
MAINCODE = SDP0018 / <alphanum-name 7..7>
This passes a message code. The caller can request an explanation of the message by means of the HELP-MSG-INFORMATION command.
RESUME-PROGRAM = *NO / *YES
This specifies whether a loaded program is to be resumed when the procedure is terminated. If *YES is specified, the most recently loaded program can be resumed when the procedure is terminated.
Note
If a procedure is called in ESCAPE mode, the following message is issued when control is returned:
TASK IS IN ESCAPE-MODE AT LEVEL NUMBER i
where i = number of the procedure level to which processing has returned.
When primary command input is reached (level 0), this message is not issued.
Return codes
With the ERROR operand, the EXIT-PROCEDURE command can report any command return code to the caller. From the caller’s viewpoint, this is the return code from the CALL-PROCEDURE or INCLUDE-PROCEDURE command. However, if execution of the EXIT-PROCEDURE command itself results in an error, control does not return to the caller but one of the following return codes is supplied and error handling within the procedure is activated.
(SC2) | SC1 | Maincode | Meaning |
---|---|---|---|
0 | CMD0001 | No error | |
2 | 0 | SSM2039 | Error on closing output system file; the SYSOUT message contains the DMS error code as an insert |
1 | CMD0202 | Syntax error | |
3 | CMD2203 | Incorrect syntax file | |
32 | CMD0221 | System error (internal error) | |
64 | SSM1013 | No procedure has been called |
Examples
See the CANCEL-PROCEDURE and HOLD-PROCEDURE commands.