Debugging ILE program in batch

From MidrangeWiki
Revision as of 22:40, 18 February 2015 by Starbuck5250 (talk | contribs) (+debugging category)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Brad Stone has a FAQ entry that addresses this: http://bvstools.com/faq.html#RPG

If that site is unavailable, here is a list of steps culled from posts to RPG400-L:

Using the Green Screen debugger:

  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.

Thanks to Bob Slaney, Phil, Patrick Conner and Kelly Fucile.

Using the IBM Distributed Debugger:

  1. SBMJOB CMD(CALL PGM(yourlib/yourpgm)) JOBQ(yourlib/yourjobq) HOLD(*YES)
  2. Start your Code debugger from Start->Programs->WebSphere Development... ->IBM Distributed Debugger->IBM Distributed Debugger
  3. Select the debugger Start up window and key into the job name entry field */##########/* where ########## is your user id.
  4. You may have to log in and specify the AS/400 system name.
  5. Select the job that is being held in yourjobq.
  6. Click the ok push button.
  7. Enter the library and program name into the Program entry field
  8. Click the Load push button on the debugger Startup information window. A debugger message will appear telling you to start the program.
  9. Click Ok on the message push button, even though it tells you to start your program first.
  10. Switch to a 5250 emulation window.
  11. WRKJOBQ JOBQ(yourlib/yourjobq)
  12. Release your job.

Answer courtesy Rob Berendt via RPG400-L 2 Aug 2001

Using the SEP debugger in green screen:

You have to at least be on V5R3. You can use SEP in green-screen debugging, although not quite so easy as in the recent releases of WDSC and RDi or RDp. This works not only for batch jobs, but for any job you want to debug different to the one you will be issuing the debug commands from.

  1. STRDBG for your program - probably UPDPROD(*YES)
  2. Put my cursor on the line where I want it to break, then press F6 - this gets me a line number that is "right"
  3. On the command line, type sbreak line-number user qtmhhtp1 (that is the usual user for CGI jobs, you would not be debugging anything else, right?)
  4. Press F12
  5. Start your server and/or do the thing in the browser that you want to debug You'll get a message in your job that says the SEP was reached. In the message is the STRSRVJOB you need to run. I do the following. It is harder to describe than to do.
  6. Put cursor on message and press F1
  7. Copy the STRSRVJOB to the clipboard
  8. Press the ATTN key (Shift-Esc on my keyboard) and press Enter
  9. Take option 1 and press Enter to go to alternative job
  10. Sign on
  11. Paste the STRSRVJOB command and press enter - maybe CALL QCMD first
  12. STRDBG the same as above - it will show you where it stopped
  13. Put cursor on that line and press F6
  14. Press F12
  15. ATTN option 1 and press Enter to go to original job
  16. Press Enter twice to release the job
  17. ATTN option 1 and press Enter to go back to alternative job - it should be positioned at the breakpoint
  18. Walk through the code as usual

Reference: http://archive.midrange.com/rpg400-l/201102/msg00419.html © midrange.com

Answer courtesy Vern Hamberg via RPG400-L 22 Feb 2011

IBM i Debugger

In addition to the above mentioned debuggers, IBM i supports another debugger - this one is called the IBM i debugger (or in older documents, System i Debugger). It comes in two forms: one, as part of the IBM i Navigator's Run SQL Scripts, and the other as JAR files in the IBM Toolbox for Java (5770-SS1 option 3, Extended Base Directory Support).

The easiest way by far to run the IBM i Debugger is to start IBM i Navigator for Windows and invoke the Debug function. The alternative requires you to copy two JAR files to your PC (jt400.jar and tes.jar) from /QIBM/ProdData/HTTP/Public/jt400/lib/ After copying them, add them to your PCs CLASSPATH. Once installed, to run the debugger, there are two steps for each debug session:

  1. Start the debug manager: java utilities.DebugMgr
  2. Start the System Debugger: java utilities.Debug <args>

<args> represents any of the following command arguments:

-u User
-s System name
-j Job description, in the form of: job number/job user/job name
-p Program to run, in the form of: program library/program name

Note: Once you use Debug Manager to register your client, you can issue the Start Debugging (STRDBG) CL command from an emulation session to start System Debugger. You can also start System Debugger directly from System Debug Manager.