How to Debug a Batch Program

How do I debug an RPG program in batch?
Submit your program into batch and make sure it is held. Do this by either holding the job queue that you are submitting the job to, or use the HOLD(*YES) option on the SBMJOB command.

Use the WRKUSRJOB and display the job you with to debug with the display job option (5).

Write down the user name, job name and number.

Start a service job using STRSRVJOB entering the name, job name and number from the previous step.

Release your submitted job by releasing the job queue or the job itself.

A display will appear asking you to press F10 function key. Press F10 and you will be brought to a command line.

Enter DSPMODSRC and enter your breakpoints.

Leave source display and command line by pressing F3 until you are back to the screen that asks you to press F10 to enter breakpoints.

Press Enter to start your job.

After that the job begins running and stops at the first breakpoint reached.
Also, you can create a simple CL to combine the two commands to make it easier to use. I created a command STRBTCHDBG so it is really simple to use. I might post the source to that later.