Debug batch jobs submitted to a job queue

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:

  1. Submit the batch job using the Submit Job (SBMJOB) command or a program that automatically submits the job with HOLD(*YES).
    SBMJOB HOLD(*YES)
  2. 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 Submit Job (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.

  3. 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)
  4. 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.
  5. 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.
  6. Use the Command Entry display to enter any debug commands, such as the Add Breakpoint (ADDBKP) or Add Trace (ADDTRC) commands.
  7. Press F3 to leave the Command Entry display, and then press Enter to start the batch job.
  8. 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.
  9. 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.
Related information
Add Breakpoint (ADDBKP) command
Add Trace (ADDTRC) command
CL command finder