Log CL procedure commands

You can specify that most CL commands run in a CL procedure be written (logged) to the job log.

This can be done by specifying one of the following values on the LOG parameter on the Create Control Language Module (CRTCLMOD) command or the Create Bound Control Language Program (CRTBNDCL) command when the procedure is compiled:

*JOB
This default value indicates that logging is to occur when the job's logging option is on. The option is initially set for no logging, but it can be changed by the LOGCLPGM parameter on the Change Job (CHGJOB) command. Therefore, if you create the module or program with this value, you can alter the logging option for each job or several times within a job.
*YES
This value indicates that logging is to occur each time the CL procedure is run. It cannot be changed by the CHGJOB command.
*NO
This value indicates that no logging is to occur. It cannot be changed by the CHGJOB command.

Because these values are part of the Create Control Language Module (CRTCLMOD) and the Create Bound Control Language Program (CRTBNDCL) commands, you must recompile the module or program to change them.

When you specify logging, you should use the Remove Message (RMVMSG) command with care in order not to remove any logged commands from the job log. If you specify CLEAR(*ALL) on the RMVMSG command, any commands logged prior to running the RMVMSG command do not appear in the job log. This affects only the CL procedure containing the RMVMSG command and does not affect any logged commands for the preceding or following recursion levels.

Not all commands are logged to the job log. Following is a list of commands that are not logged:

CALLPRC Start of changeCALLSUBREnd of change CHGVAR
DCL DCLF Start of changeDCLPRCOPTEnd of change
DO DOFOR DOUNTIL
DOWHILE ELSE ENDDO
ENDPGM ENDSELECT Start of changeENDSUBREnd of change
GOTO IF ITERATE
LEAVE MONMSG OTHERWISE
PGM Start of changeRTNSUBREnd of change SELECT
Start of changeSUBREnd of change WHEN  

If the logging option is on, logging messages are sent to the CL procedure's message queue. If the CL procedure is running interactively, and the message level on the job's LOG parameter is set to 4, you can press F10 (Display detail messages) to view the logging of all commands. You can print the log if the message level is 4 and you specify *PRINT when you sign off.

The log includes the time, program and procedure names, message texts, and command names. Command names are qualified as they are on the original source statement. Command parameters are also logged; if the parameter information is a CL variable, the contents of the variable are printed (except for the RTNVAL parameter).

Logging of commands affects performance.

Related concepts
Job log
Related information
CL command finder
Create CL Module (CRTCLMOD) command
Create Bound CL Program (CRTBNDCL) command
Change Job (CHGJOB) command
Remove Message (RMVMSG) command