Part 12
Types of Errors
Program logic errors
Anticipated errors
Unexpected errors
Divide by zero
Program not found
System errors
Power failure
DASD failure
Error Messages
Program sends *ESCAPE message if error
occurs while executing a CL command
If program has no error handling mechanism
in place, it sends an inquiry (*INQ) message
for response
To user for interactive jobs
To system operator for batch jobs
Error Messages
Job log shows messages
DSPJOBLOG command
Escape message
Inquiry message
Reply
Diagnostic message
Error Messages
Press F1 to see additional information about a
message
Message Files
*MSGF object stores message descriptions
Message text
Message data
Message Files
WRKMSGD command displays message details
CHKOBJ Command
CHKOBJ determines whether an object exists
Object existence test (OBJ, OBJTYPE)
File member existence test (MBR)
Object authority test (AUT)
CHKOBJ Command
MONMSG Command
Monitors program for occurrence of *ESCAPE message
Specifies action to take when message appears
May prevent *INQ message
Three parameters
MSGID identifies message(s) to monitor
Up to 50 messages may be specified
Command-Level MONMSG
Appears immediately following a command
MONMSG applies only to single command
Applies only to second CHKOBJ
PGM
CHKOBJ Mylib/Myfile *FILE
CHKOBJ Mylib/Myfile2 *FILE
MONMSG CPF9801 EXEC(CRTPF Mylib/Myfile2 RCDLEN(80))
CALL Mypgm
RETURN
ENDPGM
Program-Level MONMSG
Appears as first command in procedure
section of program
MONMSG applies to every command in
program
Unless command level MONMSG affects
command
Usually monitors for generic messages
Program-Level MONMSG
Applies to all commands
PGM
DCL
DCLF
MONMSG CPF9801 EXEC(GOTO End)
CHKOBJ MyLib/MyFile *FILE MBR(MyMbr1) AUT(*ALL)
CHKOBJ MyLib/MyFile *FILE MBR(MyMbr2) AUT(*ALL)
CALL MyPgm
End:
RETURN
ENDPGM
Mixed-Level MONMSGs
MONMSG can appear at both program level
and command level
Command level is considered first
PGM
MONMSG CPF0000 EXEC(GOTO ERRORS)
ADDLIBLE Mylib
MONMSG CPF2103
/* Already in list
*/
CHKOBJ Myfile *FILE
MONMSG CPF9801 EXEC(CRTPF Mylib/Myfile RCDLEN(80))
CALL Mypgm
RETURN
ERRORS:
DMPCLPGM
/* Dump the CL program */
MONMSG CPF0000
/* Just in case
*/
SNDPGMMSG MSG(Error occurred in program.)
RETURN
ENDPGM
*/