Batch jobs can be debugged by an interactive job.
1. Submit your program to batch. The job MUST be held. You can either hold the job queue (HLDJOBQ) or hold the individual job (HLDJOB) or specify HOLD(*YES) on the SBMJOB command.
2. WRKSBMJOB/WRKUSRJOB/WRKACTJOB and find your submitted job. Note that the SBMJOB command gives you an informational message with the job name/number. What you need is the job name, user ID and job number - the fully qualified job name. Example: 123456/BUCK/MONTHEND
3. STRSRVJOB on the held batch job.
4. STRDBG on your program. Specify UPDPROD(*YES) if needed. You'll see the source listing if you compiled with DBGVIEW(*LIST) or *SOURCE.
5. Press F12 to exit - you cannot set a breakpoint yet.
6. Release the job so that it becomes STATUS(*ACTIVE).
7. You'll see a display asking if you want to debug or continue. Press F10 to debug.
8. DSPMODSRC to see the source listing again. Alternately, press F10 to step into the first instruction.
9. Now you can add your breakpoints.
10. Press F3 until you're back to the "debug or continue" display. Press Enter to run the program with your breakpoints set.
11. When you're done, do an ENDDBG and ENDSRVJOB.
Screenshots of Debugging a batch Job is here in this link:
Batch Debug Screenshots
- Debugging batch jobs that are 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. - Debugging batch jobs that are not started from job queues
You can debug batch jobs that are started on the system but are not submitted to a job queue. These jobs cannot be stopped before they start running, but they can typically be debugged. - Debugging a job that is running
You can debug a job that is already running if you know what statements the job will run. - Debugging another interactive job
Whether a job is running or waiting at a menu or command entry display, you can debug the job from another display. - Considerations when debugging one job from another job
Although most jobs can be debugged from another job, there are some considerations you should follow.
Other Links: Debug More Information