Return to the RPG Tips
How to force an RPG Dump
Occasionally, we all manage to write an RPG program with a bug or two.
Hopefully, we find the bugs before the programs make it into the
production environment.
If we don't, no matter how unlikely the
sequence of events that exposes the bug, it's a certainty that a user
will discover it!
In such a case, an RPG formatted dump might help you determine the problem. All too often, users respond to error messages without requesting a dump. Fortunately, you can use RPG's Dump opcode to force a dump when an error occurs by including it in your error handling routine.
To demonstrate, consider the following code snippets that show portions of a Program Exception/Error Subroutine (*PSSR).
Below is a pre-V5R1 technique demonstrating how to force a dump:
H Debug( *Yes ) D PSSRError 1N Inz( *Off ) C *PSSR BegSr C If PSSRError C Eval *InLR = *On C Return C EndIf C Eval PSSRError = *On C Dump * Insert code to handle exception C EndSrNotice that there is an H-spec specifying Debug(*Yes). This is a requirement when using the Dump opcode at releases earlier than V5R1.
V5R1 removes the need to specify Debug(*Yes) by adding the A extender to the Dump opcode. With the A extender, the Dump opcode always performs the dump, regardless of the Debug attribute. This means you can remove the H-spec with the Debug keyword and simply add the A extender to the Dump opcode.
Below is a V5R1 technique demonstrating how to force a dump:
D PSSRError 1N Inz( *Off ) C *PSSR BegSr C If PSSRError C Eval *InLR = *On C Return C EndIf C Eval PSSRError = *On C Dump(A) * Insert code to handle exception C EndSr
[report a broken link by clicking here]