Welcome, brave IBM AS400, iSeries, and IBM i warriors, to the wild world of debugging RPG code!
Whether you’re slinging legacy RPG or rocking the modern Free Format vibe on the IBM i Power System, one thing’s for sure: bugs happen. If your subfiles are staging a revolt, your data’s gone AWOL, or your boss just muttered ‘fix it by lunch,’ this blog’s for you. Those sneaky little gremlins can turn your perfectly planned subfile into a head-scratcher.
Debugging isn’t just a good idea—it’s your ticket to surviving the green-screen jungle without losing your sanity (or your coffee).
Fear not, debugging RPG programs is a skill you can master, and I’m here to walk you through the basics.
Let’s fire up the IBM i debugger and get those programs back on track! So, come with me while we grab our magnifying glasses, channel our inner Sherlock, and turn those program meltdowns into victories.
Debugging RPG on IBM i: A Solid Guide for the Trenches
Debugging an RPG program on the IBM i isn’t exactly a comedy show, but it’s a rite of passage for us IBM i programmers. I recently tackled a misbehaving subfile, and here’s my quick, no-nonsense review of the key steps:
Set the Stage (Compile options for best debug results)
Before you debug, compile your RPG with CRTBNDRPG and DBGVIEW(*SOURCE). It’s your lifeline to see the actual code in the debugger—not some cryptic mess. Skip this, and you’re guessing in the dark. It’s straightforward, but you’ll kick yourself if you forget.
Use STRDBG to go into DEBUG MODE
Type STRDBG PGM(MYLIB/MYPGM) and you’re in business. This tool’s the real deal—set breakpoints with BREAK 50 where you suspect trouble (line 50’s usually up to no good). Call your program, and the debugger freezes it right where you need to dig in. Reliable and clutch.
Step and Inspect
Use F10 to step line-by-line or F11 to peek into subprocedures. Check variables with EVAL MYFIELD—like when I found my CUSTID was blank due to a sloppy READ. You can even tweak values on the spot. It’s powerful, though it takes focus to follow the trail.
Track, Pinpoint the Problem Solve
Subfile not displaying? Check your RRN logic. File operation bombing? Look at %STATUS or key mismatches. The debugger lays it out, but you’ve got to connect the dots. It’s detective work—satisfying when it clicks, tedious when it doesn’t.
Fix and Finish
Once you’ve caught the bug, ENDDBG lets you escape. Update your code, recompile, and test. It’s a clean exit with a sense of victory—assuming the fix holds. No complaints here; it’s the payoff for the grind.
Debugging RPG on IBM i with STRDBG is a solid process—structured, effective, and worth learning. It’s not glamorous, but it gets the job done. 4.5 stars—loses half a point for the mental gymnastics, but that’s just the RPG life.
Want to see a quick Debug of an RPG SUBFILE?
You can watch the entire Writing, Testing and Debugging RPG subfiles here
Or you can simply watch me muttering insanely to myself, while trying to describe the most basic tenets of IBM i Debugging to new programmers:
Get in there and tame those bugs, IBM i crew!