RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

How to force an RPG Dump Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   
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:


Thanks to the as400pro.com


	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                   EndSr

Notice 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
<Previous   Next>