z/OS TSO/E CLISTs
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


&LASTCC

z/OS TSO/E CLISTs
SA32-0978-00

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.

&LASTCC can be used in error routines that handle multiple error conditions. For example, if an error routine handles arithmetic errors, it can use &LASTCC to determine what type of message to display at the terminal:
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.
When an error occurs during CLIST I/O processing, use an error routine to obtain the error code in &LASTCC. For example, to trap the error code generated by OPENFILE when attempting to open a file (BADFILE) that does not exist, code the following CLIST:
PROC 0
ERROR DO
SET RC=&LASTCC.
RETURN
END
OPENFILE BADFILE
WRITE LASTCC=&RC

See Table 1 for a list of the CLIST error codes that &LASTCC can contain.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014