To start debugging a running batch job is very
easy with VISUAL Debugger. However, debugging a batch job from the very first
line has always been complex. A trick you can use is to set a delay job (DLYJOB)
command at the very beginning of the program before submitting the batch job
to a job queue, but it is not the best option in many cases. However, you can
start debugging batch jobs from the first line (or any line, by setting a breakpoint
where you want it) by following an easy series of steps. Happy debugging!
|
1. Submit the job, and retain it in the
job queue.
|

Click on the image to enlarge it |
To retain a job in the job queue:
- Stop the subsystem
- Hold the job queue
- Submit the job with the parameter hold on job
queue (HOLD) to *YES.
Once the job has been submitted,
retrieve its job name, user and number using the WRKJOBQ command (see
Figure)
In this case the job is C_PGM/ROBERTO/287919
|
| 2. Start servicing the job in the
JOBQ from an interactive job. |
| From a command line enter the following
command:
STRSRVJOB JOB(number/user/name),
In our example, we should enter STRSRVJOB JOB(287919/ROBERTO/C_PGM).
|
| 3. Start VDW specifying the interactive
job
|
|

Click on the image to enlarge it
|
Start VDW. Choose the
program you want to debug and the interactive job from which you entered
the STRSRVJOB command. All the debug commands will take effect on the interactive
job that is servicing the job in the job queue.
Note that the job we are going to select is interactive
and is the one from which the STRSRVJOB command was entered
|
|

Click on the image to enlarge it
|
Although VDW shows you the program source, you cannot
yet set breakpoints, because the job is not active.
Note the CPF1938 error that happens if you try to set
a breakpoint while the job is not active.
|
| 4. Release the job in the job queue and
set the breakpoints |
|

Click on the image to enlarge it
|
When you release the job, you will see the following screen
appearing on the interactive screen: |
|

Click on the image to enlarge it
|
This is when you can set your breakpoints in VISUAL Debugger
for Windows. DO NOT PRESS [ENTER] or [F10] until youve finished setting
your breakpoints in VDW. |
|

Click on the image to enlarge it
|
When finished, release the job by pressing enter in the
interactive screen. |
| The program has started its execution and
stops on the breakpoint previously set. |