CL Programming
You may want to use a separate job to debug programs running in another job
for one of the following reasons:
- Batch jobs can be debugged by an interactive job.
- An interactive job can be debugged from another interactive job.
This allows one display to show debug information without interrupting the
application program display.
- An interactive or batch job that is looping can be interrupted and put
into debug mode.
Using a separate job to debug another batch job submitted to the job queue
allows you to put the batch job into debug mode and to set breakpoints and
traces before the job starts to process. Use the following steps to
debug batch jobs to be submitted to a job queue:
- Submit the batch job using the Submit Job (SBMJOB) command or a program
that automatically submits the job with HOLD(*YES).
SBMJOB HOLD(*YES)
- Determine the qualified job name (number/user/name) that is assigned to
the job using the Work with Submitted Jobs (WRKSBMJOB) command or the Work
with Job Queues (WRKJOBQ) command. The SBMJOB command also displays the
name in a completion message when the command finishes processing.
The WRKJOBQ (Work With Job Queue) command displays all the jobs waiting to
start in a particular job queue. You can show the job name from this
display by selecting option 5 for the job.
- Enter the Start Service Job (STRSRVJOB) command from the display you plan
to use to debug the batch job as follows:
STRSRVJOB JOB(qualified-job-name)
- Enter the STRDBG command and provide the names of all programs to be
debugged. No other debug commands can be entered while the job is
waiting on the job queue.
- Use the Release Job Queue (RLSJOBQ) command to release the job
queue. A display appears when the job is ready to start, indicating
that you may begin debugging the job. Press F10 to show the Command
Entry display.
- Use the Command Entry display to enter any debug commands, such as the Add
Breakpoint (ADDBKP) or Add Trace (ADDTRC) commands.
- Press F3 to leave the Command Entry display, and then press Enter to start
the batch job.
- When the job stops at a breakpoint, you see the normal breakpoint
display. When the job finishes, you cannot add breakpoints and traces,
or display or change variables. However, you can display any trace data
using the Display Trace Data (DSPTRCDTA) command.
- If you wish to debug another batch job, first end debugging using the End
Debug (ENDDBG) command and then end servicing the job using the End Servicing
Job (ENDSRVJOB) command.
Some jobs started on the system are not submitted to a job queue.
These jobs cannot be stopped before they start running but they can usually be
debugged. To debug jobs not started from a job queue, do the
following:
- Rename the program that is called when the job starts. For example,
if the job runs program CUST310, you can rename this program to
CUST310DBG.
- Create a small CL program with the same name as the original program
(before the program was renamed). In the small CL program, use the
Delay Job (DLYJOB) command to delay for one minute and then use the CALL
command to call the renamed program.
- Allow the batch job to start to force the CL program to be delayed for one
minute.
- Use the Work with Active Jobs (WRKACTJOB) command to find the batch job
that is running. When the display appears, enter option 5 next to the
job to obtain the qualified job name.
- Enter the Start Service Job (STRSRVJOB) command as follows:
STRSRVJOB JOB(qualified-job-name)
- Enter STRDBG and any other debug commands, such as the Add Breakpoint
(ADDBKP) or Add Trace (ADDTRC) command. Proceed with debugging as
usual.
You can debug a job that is already running if you know what statements the
job will run. For example, you may want to debug a running program if
the job is looping or the job has not yet run a program that is to be
debugged. The following steps allow you to debug a running job:
- Use the Work with Active Jobs (WRKACTJOB) command to find the job that is
running. When the display appears, enter option 5 next to the job to
obtain the qualified job name.
- Enter the Start Service Job (STRSRVJOB) command as follows:
STRSRVJOB JOB(qualified-job-name)
- Enter the Start Debug (STRDBG) command. (Entering the command does
not stop the job from running.)
- Note:
- You can use the Display Debug (DSPDBG) command to show the call stack.
However, unless the program is stopped for some reason, the stack is correct
only for an instant, and the program continues to run.
- If you know a statement to be run, enter the Add Breakpoint (ADDBKP)
command to stop the job at the statement.
If you do not know what statements are being run, do the following:
- Enter the Add Trace (ADDTRC) command.
- After a short time, enter the Remove Trace (RMVTRC) command to stop
tracing the program.
- Enter the Display Trace Data (DSPTRCDTA) command to show what statements
have processed. Use the trace data to determine which data statements
to process next (for example, statements inside a program loop).
- Enter the Add Breakpoint (ADDBKP) command to stop the job at the
statement.
- Enter the desired debug commands when the program is stopped at a
breakpoint.
You can debug a job from another display, whether the job is running or
waiting at a menu or command entry display. To debug another
interactive job, do the following:
- Determine the qualified job name of the job to be debugged. To
determine the name, either enter the Display Job (DSPJOB) command from the
display of the job to be debugged, or use the Work with Active Jobs
(WRKACTJOB) command.
- Enter the Start Service Job (STRSRVJOB) command using the qualified job
name.
- Enter the Start Debug (STRDBG) command and any other debug commands
desired. If the job is already running, you may need to enter the
Display Debug (DSPDBG) command to determine what statement in the program is
processing.
When the job being debugged is stopped at a breakpoint, the display station
is locked.
Although most jobs can be debugged from another job, you must take the
following into consideration:
- A job being debugged cannot be held or suspended (for example, when
running another group job or a secondary job).
- When servicing another job with the Start Service Job (STRSRVJOB) command,
you cannot also debug the job doing the servicing. All debug commands
apply only to the job being serviced. To debug the job doing the
servicing, you must either end the servicing of the other job, or have another
job service and debug it.
- Debug commands operate on another job, even if that job is not stopped at
a breakpoint. For example, if you are debugging a running job and you
enter the Display Program Variable (DSPPGMVAR) command, the variable you
specify is shown. Since the job continues to run, the value of the
variable may change soon after the command is entered.
- A job being debugged must have enough priority to respond to debug
commands. If you are debugging a batch job with a low priority and that
job gets no processing time, then any debug command you issue waits for a
response from the job. If the job does not respond, the command ends
and an error message is displayed.
- You cannot service and debug a job that is debugging itself.
However, you can service and debug a job that is servicing and debugging
another job.
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.