Debug Active Job

If you want to debug a batch job or an already active job you can do that by using STRSRVJOB.

  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. Use any of the following commands WRKSBMJOB or WRKUSRJOB or WRKACTJOB and find your submitted job. Note that the SBMJOB command gives you an informational message with the job name/number. You need the job name, user ID and job number - the fully qualified job name.
  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.
  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. Use DSPMODSRC to see the source listing again. Now you can add your breakpoints if you want.
  9. Press F3 until you're back to the “debug or continue” display. Press Enter to run the program with your breakpoints set.
  10. The process breaks at the first break-point installed and gives you the control.
  11. When you're done, do an ENDDBG and ENDSRVJOB.

Original post: