Your IBM i Power System (not its not an AS400 and no its not an ISERIES don’t trigger me!) is a digital hoarder’s paradise, stuffed with decades of code.
Now, an OS upgrade or a PTF (Program Temporary Fix, aka IBM’s version of a software Band-Aid) changes a command’s behavior. Suddenly, you need to recompile any program using it… Aaaargh!
PRTCMDUSG swoops in like a superhero (quite a lazy superhero but more on that in the next paragraph), listing every CL program that mentions the command, so you know what’s at stake. It’s also a lifesaver for auditing or potentially deleting unused commands without causing a system meltdown.
BE CAREFUL – This IBM command is from the good old days of the mighty System38 when Control Language Programs were King. During testing I have found that it lists CLP programs that reference commands but sadly ignores the next generation of CLLE programs and SQLRPGLE or RPGLE programs. Sloppy work IBM Propellor Heads!
Meet PRTCMDUSG
PRTCMDUSG is like that friend who’s always got the dirt. It creates a spooled file (fancy IBM-speak for a report) listing where your chosen commands show up in CLP programs or ILE CL modules. You can check up to 50 commands at once, and it’ll rummage through specific programs, libraries, or even the whole system if you’re feeling wild. Warning: on a beefy system, this can take a hot minute and spit out a report longer than a CVS receipt, so maybe grab a coffee.
How to Use PRTCMDUSG Without Losing Your Mind
Good news: PRTCMDUSG is so easy, you could probably run it while half-asleep. All you need is *USE authority for the commands and programs you’re snooping on. Here’s the game plan:
Get to a Command Line: Fire up your 5250 emulator (or flex with SQL remote command function if you’re extra). You know the drill.
The Command Itself: It’s as simple as:
PRTCMDUSG CMD(MYLIB/MYCOMMAND) PGM(*ALLUSR/*ALL)
PRTCMDUSG: The IBM i Command that does the magic
Parameter CMD: The star of the show. Pick the command you’re curious about, like *LIBL/CPYF for the Copy File command. You can list up to 50 if you’re feeling ambitious.
Parameter PGM: Optional, but it’s where the magic happens. Defaults to user libraries, but you can go specific (PAYROLL/MYPROG) or wild with *ALL to scan an entire library.
Try It Out
Wanna know if CPYF is hiding in your PAYROLL library? Just type:
PRTCMDUSG CMD(CPYF) PGM(PAYROLL/*ALL)
Hit Enter, and boom, a spooled file is born, listing every program where CPYF makes an appearance.
Run WRKSPLF (Work with Spooled Files) to peek at the report. It’ll say something like:
- Command: CPYF
- Used in: PAYROLL1, PAYROLL2, etc. If it’s crickets, congrats, that command’s not in your code!
Is It Really That Easy?
On a scale of “rocket science” to “making toast,” PRTCMDUSG is firmly in toast territory.
Seriously:
- No setup nonsense: It’s built-in, no extra tools needed.
- Barely any parameters: Just CMD and PGM. Forgot the syntax? Hit F4 to prompt it.
- Instant results: Run it from any command line, no PhD required.
- Readable output: It’s basically a list saying, “Yup, found it here!”
But, like that one friend who’s great but not perfect, PRTCMDUSG has limits. It only spots static command references in CL code. If someone’s sneaking commands through APIs like QCMDEXC or SQL shenanigans, it won’t catch those. For that, you’ll need to get fancy with object auditing (CHGOBJAUD) or exit points like RTV_CMD.
Want to track actual command executions? That’s a job for QAUDJRN journal auditing, but that’s a whole other adventure and a different blog entirely 🙂
PRTCMDUSG is one of many unsung heroes of IBM i commands, making it stupidly easy to figure out what’s being used on your box. Whether you’re tidying up, securing the fort, or just curious, it’s got your back. Next time you’re staring at a command wondering, “Does anyone even use this?”, let PRTCMDUSG do the heavy lifting. You’ll be back to sipping your mug of Yorkshire Tea in no time.

