Page 1 of 1

Dumps with RPG Programs with Subprocedures

Posted: Thu Feb 02, 2023 8:16 pm
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?

Re: Dumps with RPG Programs with Subprocedures

Posted: Fri Feb 03, 2023 6:01 pm
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.