Returns the current system return code or sets a new return code value.
&RETCODE [ value ]
&RETCODE may be referenced as a system variable to return the current return code value or as a verb to set a new value.
A nested procedure can set a return code on the &END statement. On return to the higher level, &RETCODE contains the return code value. In addition, many NCL functions can set &RETCODE as an indication of the success or otherwise of the function.
&RETCODE is in the range 0 to 99 and is used to indicate the completion of a function performed by a nested procedure.
When used as a verb, &RETCODE sets the value of the &RETCODE variable.
Operands:
A new value in the range 0 to 99 to be placed in &RETCODE.
Examples: &RETCODE
&GOSUB .GETREQ
&IF &RETCODE NE 0 &THEN +
&DO
&SYSMSG = &STR NO REQUESTS IN QUEUE
&RETCODE 4
&RETURN &SYSMSG
&DOEND
&CONTROL FINDRC EXEC &REQUEST &IF &RETCODE EQ 100 &THEN + &WRITE DATA=Requested Procedure &REQUEST not found
A procedure may set a value in the range 0 to 99 for &RETCODE. A value of 100 is set by the system if the &CONTROL FINDRC option is set. This option allows a procedure to determine the success of a request for a nested procedure. If the requested procedure does not exist and &CONTROL FINDRC is set processing continues but &RETCODE is set to a value of 100. If &CONTROL FINDRC is not set, the requesting procedure will terminate.
If no user exit is installed, &SECCALL EXIT sets the &RETCODE to 100.
When a process is initiated, &RETCODE will have a default value of 0.
An alternative to using the &END statement to pass a return code is to use the &RETURN statement, which can return variables to a higher nesting level, or &CONTROL SHRVARS, which allows sets of variables to be shared between procedures.
The &RETSUB statement may be coded with a value to be set as &RETCODE. Alternatively, &RETCODE is set within the body of the subroutine.
| Copyright © 2009 CA. All rights reserved. |
|