i Have a CL program in which commands are added quite frequently . Because of the frequent addition of commands - adding command level MONMSGs to monitor each error is rendering the program BULKY. Is there any way to trap all possible error messages on all the commands in the CL program without using a Command Level MONMSG.
Using program level MONMSG like CPF0000 will trap all errors - and then the user can be informed that an error has taken place using SNDPGMMSG. However, how will the user be informed of the exact error message - and on which CL command the error takes place on ??
Software/Hardware used:
ASKED:
March 21, 2005 4:28 AM
UPDATED:
April 8, 2005 12:06 PM
PGM
DCL VAR(&PROCESS) TYPE(*CHAR) LEN(20) +
VALUE(‘Start up’)
DCL VAR(&ERRORMSG) TYPE(*CHAR) LEN(80)
MONMSG MSGID(CPF0000) EXEC(GOTO ERROR)
CHGVAR VAR(&PROCESS) VALUE(‘Initialize Tape’)
INZTAP DEV(TAP01)
CHGVAR VAR(&PROCESS) VALUE(‘Save Library ABC’)
SAVLIB LIB(ABC) DEV(TAP01)
GOTO CMDLBL(ENDPGM)
ERROR:
RCVMSG MSGTYPE(*EXCP) RMV(*NO) MSG(&ERRORMSG)
SNDPGMMSG MSG(‘An error occured during:’ |> + &PROCESS)
SNDPGMMSG MSG(&ERRORMSG)
ENDPGM: ENDPGM
If I recall well, you can restrict the monmsg also to a range f.e. MONMSG CPF4000 will catch all errors in the 4001-4999 range. Combined with the CL you should be able to catch messages and treat them accordingly
rchevalier had already provided you a perfect solution. I just want to highlight that most CL commands allow R=Retry choice after clearing the encountered error. It may not be a good idea (especially from production support point of view) to have a “MONMSG ALL” CL job.