Dumps with RPG Programs with Subprocedures

Discussions relating to writing software in ILE RPG (RPG IV). This includes both fixed and free format RPG.
Post Reply
Posts: 47
Joined: Wed Jul 06, 2022 7:52 pm

Dumps with RPG Programs with Subprocedures

Post by bbunney »

If a program error occurs within a subprocedure and you have a PSSR routine in the program not in a subprocedure that executes a Dump and/or you respond to the error message with a 'D', the local variable values in the subprocedure do not have any values in the dump unless you have a *PSSR routine in the subprocedure and dump it there. Do RPG programmers these days put *PSSR routines in their subprocedures, rely on Monitor groups or do something else?
Scott Klement
Site Admin
Posts: 720
Joined: Sun Jul 04, 2021 5:12 am

Re: Dumps with RPG Programs with Subprocedures

Post by Scott Klement »

I suspect my response won't be very helpful for you -- I've never found dumps to be useful. Even in RPG III (RPG/400) I avoided them, I prefer to use a debugger to step through my code and see what's going on. Or if stepping through the code takes too long, I insert some kind of logging/printing/diagnostic messages in the code where I need them.

The reason you're having problems is because the variables are out of scope. They are created when the subprocedure starts, and deleted when it ends. This is normal -- and the same concept exists in virtually every programming language -- the only exception I can think of is CL. If you want to see the variables, you need to display them (in the debugger, logging, or the DUMP opcode, whatever) when the subprocedure is still active.

I haven't coded *PSSR (at any level) in probably 15 years. I use the MONITOR opcode to catch errors -- but the concept is still the same, you have to do it while the subprocedure is still active.
Post Reply