The ERRORTEXT option holds the text of the first error message that occurs when you execute a program or a statement. The name of the error whose message is found in ERRORTEXT is contained in the ERRORNAME option.
In a report program that uses a TRAP command to handle errors, you can use the SIGNAL command to send the appropriate error message to the current outfile.
DEFINE myreport PROGRAM LD Monthly Report PROGRAM TRAP ON CLEANUP NOPRINT PUSH month DECIMALS LSIZE PAGESIZE LIMIT month TO LAST 1 ... POP month DECIMALS LSIZE PAGESIZE RETURN CLEANUP: POP month DECIMALS LSIZE PAGESIZE SIGNAL ERRORNAME ERRORTEXT END