Tuesday, March 31, 2009

DEBUGGING BATCH JOBS

Steps to debug a batch job -
1. SBMJOB ... HOLD(*YES)

2. STRSRVJOB JOB(jobnbr/user/jobnam)

3. STRDBG
When source is displayed, press F12

4. RLSJOB JOB(jobnbr/user/jobnam)
When Start Serviced Job display appears, press F10

5. When command entry display is shown, DSPMODSRC
When source is displayed, set a breakpoint, then press F12
When command entry display is shown, press F12

6. When Start Serviced Job display reappears, press Enter
Program will stop at breakpoint, and can be debugged interactively

7. After serviced job ends
ENDDBG
ENDSRVJOB

In detail, some explanations -


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) 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.

2. Enter the Start Service Job (STRSRVJOB) command from the display
---->
STRSRVJOB JOB(qualified-job-name)

3. 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. )

4. 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.

5. Press F10 to show the Command Entry display. DSPMODSRC. 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 want 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.

6 comments: