Did you ever have a CL/RPG ILE program crash on you and give you a statement number where the error occurred such as: RPG procedure TESTCRASH in program LADOUCEUR/TESTCRASH at statement 5 tried to divide by zero? Normally you would have to generate a compile listing and look for statement 5. But there is an easier way. If you compile your ILE program with DBGVIEW (*LIST) then after an error occurs and you answer the answer the message and cancel the program, you just key StrDbg programname at the command, and key: Down 5 at the debug command line for an RPGLE, or key: find 5- for a CL (the dash is important for CL's). Then you will be presented with the statement that caused the problem as the very top line of viewable code. Sample compile: CRTBNDRPG PGM(LADOUCEUR/TESTCRASH) DBGVIEW(*LIST) The Debug technique comes in handy in very large programs where the time to compile/print a listing is long or if you are not sure you have the correct source code.
If you don't want to remember to specify DBGVIEW(*LIST) then you can do what I have done. I have permanently changed CRTBNDRPG and CRTBNDCL command to DBGVIEW(*LIST) with these commands: CHGCMDDFT CMD(CRTBNDRPG) NEWDFT('DBGVIEW(*LIST)'), CHGCMDDFT CMD(CRTBNDCL) NEWDFT('DBGVIEW(*LIST)')
Be aware that compiling a program with *LIST does take a little more storage space in the system, but you will always have matching source code and a quick way to find the offending line of code.
Sample Crash program D a s 10 0 Inz(10) D b s 10 0 inz(0) C Eval *inlr=*on * Bad division C eval A = A / B
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.