Why there is a need of MSGCLASS in the cobol source program or cobol code?

The MSGCLASS=x is used to specify where the job output will be directed. The output classes are predefined and vary from site to site. Two of the normal defaults are as follows.

A Normal system printing and all output listings sent to the default system printer.

O Hold output in the queue and allow job output to be viewed on-line through the TSO outlist facility.

Two of the normal Message Class defaults
The MSGLEVEL=(x,y) is used as follows.(Entries for the “X” Value of Message Level)

0 The system prints only the JOB statement.

1 The system prints all JCL statements, JES2, or JES3 control statements, the procedure statements, and IEF653I messages which show the values assigned to symbolic parameters in procedure statements.

2 The system prints only JCL statements and JES2 and JES3 control statements.

(Entries for the “Y” Value of Message Level)

0 The system prints only JCL messages. It prints JES and operator messages only if the job abnormally terminates.

1 The system prints JCL messages and any JES and operator messages.

If you want to be notified when the job has finished then use the “NOTIFY=” key word. The NOTIFY parameter must specify a valid user-id.