&LASTCC
When you use &LASTCC outside an error routine, &LASTCC contains the return code from the last TSO/E command or subcommand, nested CLIST, or CLIST statement executed. Because the value of this variable is updated after the execution of each statement or command, store its value in a symbolic variable before executing code that references the value.
In an error routine, &LASTCC is not updated after the execution of each statement or command. Only the RETURN statement updates the value of &LASTCC. If you use &LASTCC in an error routine, &LASTCC contains the return code from the command or statement that was executing when the error occurred.
&LASTCC does not support negative return codes. When a negative return code is received from a REXX exec, CLIST converts it to binary, removes the first byte, and stores the remainder in &LASTCC as a positive decimal integer.
When &LASTCC receives an error return code from a TSO/E command, subcommand, nested CLIST, or CLIST statement, control passes to an error routine if present in the CLIST. However, when &LASTCC contains the return code from a subprocedure RETURN statement, control does not pass to an error routine.
ERROR +
DO
SET RCODE = &LASTCC
/* Character data in operands? */
IF &RCODE = 852 THEN +
WRITE Character data was found in numbers being added.
/* Numeric value too large? */
IF &RCODE = 872 THEN +
WRITE A numeric value in the addition was too large.
(Other tests)
⋮
RETURN
END
SET SUM = &VALUE1 + &VALUE2 + &VALUE3; Note
that &LASTCC itself does not get updated within the error routine.PROC 0
ERROR DO
SET RC=&LASTCC.
RETURN
END
OPENFILE BADFILE
WRITE LASTCC=&RC