Over the past few years, the programming languages available on the AS/400 have evolved into more than simple report-generating programming tools. RPG itself has progressed, with the introduction of ILE, into a means to produce code that is reusable throughout entire application systems.
Putting to use the creation of modules and service programs in your applications makes previously used CALLs and subroutines copied from program to program no longer necessary. This makes code easier to write and maintain because programmers are able to encapsulate smaller functions into external pieces of code, usable from the major pieces of application software. In turn, this also makes code easier to debug because, if one of these modules is performing wrong in one program, it will also be performing wrong in every other instance that it is used.
Finally, making use of ILE in applications makes fixing bugs easier. This is because, if the bug is contained within a service program, fixing it is as simple as correcting the module code, re-creating or updating the service program, and applying the fixed code to the live environment. In the past, some of these fixes required going through every program containing the subroutine with the error, recompiling, and moving these updated programs into productionsomething most programmers didnt enjoy.
Enter the ILE Debugger
The movement to ILE, or even simply to RPG IV, forced programmers once again to learn something new. It seems to always work this way. As soon as you master one thing, something newer comes along. Usually this new piece of technology is vaguely similar to its predecessor. What I am referring to is the move from the Interactive Source Debugger (ISDB) to what is called the ILE Debugger.
This is a necessary change because ISDB doesnt work on ILE objects. This includes program attribute types RPGLE and CLLE, as well as modules and service programs. So, you have two choices: Stick with Original Program Model (OPM) RPG and ISDB or make the move to ILE and learn a few new tricks to debugging. I hope you choose the latter, which is a much more rewarding move. In the following sections, I will compare and contrast the two debuggers to help make the transition a little easier and maybe give a nudge to those of you still on the fence.
Old Faithful vs. the New Kid on the Block
Its hard to compare two tools that work on totally different object types. If youre using an OPM programming language, such as RPG III, you really dont have much of a choice but to use ISDB. By the same token, if youre programming with RPG IV or any other ILE programming language, then the ILE Debugger is your tool of choice. But if youre planning on making the switch from RPG III to RPG IV, or you want to brush up on your debugging knowledge after making the switch, this information should help.
Figure 1 (page 122) shows a list of common commands for both debuggers. Viewing the help available for either debugger is a great starting place to get familiar with all the commands. Both debuggers have help screens that are interactive. They start by listing available commands, as well as any shortcut commands, you can use. Moving your cursor over one of the commands and pressing Enter will bring up an extended description of that command. I find this type of help screen intuitive and easy to navigate.
The biggest difference between these two debugging tools is how they display a variable. Both debuggers still allow you to move your cursor to the variable you wish to see and press F11. But, on the command line, you use the Display (DSP) command with ISDB and the EVAL command with the ILE Debugger.
The DSP command doesnt exist in the ILE Debugger, but a similar command, DISPLAY, does. This command, however, is used to display expressions set up with the EQUATE command or to display a different modules source code.
The EVAL command can also be used to change the contents of a variable; ISDB uses the Change (CHG) command. Finally, if you like putting watches on variables, ISDB uses the WATCH and UNWATCH commands to place and remove watches, respectively, on fields. With the ILE Debugger, the WATCH command is still used to place a watch, but to remove one, you specify the WATCH command with no arguments, displaying a list of the current watches assigned. You then use the Clear option (option 4) to remove a watch.
Youll also notice that ISDB offers a couple of commands not available in the ILE debugger. These are mainly the Print (PRTxx) commands. I had never used these commands in ISDB before, and, when I tried them out, I was pleasantly surprised to find out what they did, even though it wasnt really anything more than a print screen of the DSP command.
Although some of the niceties of ISDB were not implemented in the ILE Debugger, such as color-coding the source, some of the annoyances are also missing. For example, when using ISDB to display or print a variables contents, the display was limited to the first 200 characters of the field. If youre like me, you build large query select statements in a CL; this could cause a problem. The ILE Debugger seems to have no limit in the size of a variable it can display.
Figure 2 shows a list of common function keys used in each debugger. It seems again that ISDB wins hands down for functionality and ease of use. Of course, the only commands extant in ISDB that are absent from the ILE Debugger are the aforementioned print commands.
The biggest change in command keys is the STEP command key, which allows you to step, line by line, through the source code. ISDB uses F5, and the ILE Debugger uses F10. How to tell the debugger to run until the next breakpoint or variable being watched differs as well. For IDSB, you use the F17 key. The ILE Debugger uses F12. One great improvement with the ILE Debugger is the addition of the Step Into (F22) function key. This allows you to step into a call to another program or a subprocedure (more on the F22 function key later in this article).
ILE Debugger Views
Before you can begin to debug your ILE programs, you need to know that there are some defaults on the CRTxxx commands that allow you to control the level of debug. This
option on the Create Bound RPG Program (CRTBNDRPG) and Create RPG Module (CRTRPGMOD) commands, is the Debug View (DBGVIEW) option. The values available for this option are *NONE, *STMT, *SOURCE, *LIST, *COPY, and *ALL. Figure 3 contains a reference to these options, as well as a short description of each.
*NONE is fairly self-explanatory. It will not allow debugging on the program at all. *STMT is reminiscent of the days when you had to debug without a view of the source. It allows you to debug your programs, but it lets you step through the source so you can see where you are. *SOURCE gives you a listing to view when debugging, to keep track of your place in the program. This option shows the source exactly as it is displayed in the source file; for example, the /COPY data is not copied into the listing, or files are not expanded. *LIST creates a view similar to a compile listing. Files are expanded, and /COPY members are displayed in the view. *COPY will copy the /COPY members into the view, but, other than that, its the same as using *SOURCE. *ALL creates all of the views I just mentioned.
Some ILE Debugger Tricks
Since I havent really programmed an RPG III program for quite some time, I have grown unfamiliar with the ISDB. But researching this article brought back a few memories. It also made me appreciate one command in the ILE Debugger that makes viewing programs or subprocedures called by a program much easier. This is the Step Into (F22) function key I mentioned before. If you program using real ILE, then you no doubt use a bunch of service programs and modules. When you are on a command that calls one of your subprocedures, using the Step Into function key brings you right into that subprocedure. This is, of course, if you used one of the compile options that allows you to see the source while debugging.
This may seem pretty straightforward on commands such as CALL or CALLP, but what about those subprocedures that return a value? Assume you have a subprocedure that is passed a string of text and returns it centered. The call would look something like this:
Eval Result = Center(Text)
In this case, Center() is the function that returns centered text. To step into this call and debug the subprocedure behind it, simply use the F22 key. The same goes if the function is used on a SELECT or IF statement.
One problem with the ILE Debugger up until V4R4 (or by applying the appropriate service pack for versions down to V3R2 as shown in Figure 4) is that, if you are debugging and come to an I/O statement, such as READ or CHAIN, you have to use the Step function key a few times until it goes past that statement. Well, IBM heard your cries and now allows you to specify a compile option (or H-spec), telling the debugger to skip over these commands. Specifying OPTION(*NODEBUGIO) on the CRTxxx command will determine if breakpoints are specified for I/O operations.
We All Get Bugs
As perfect as most of you are at turning out great code, it is inevitable that, at one point or another, youll end up with a bug in your code. IBM has supplied a couple of debuggers that help programmers help themselves find these bugs. It never fails. Sure, neither is perfect, but whether youre using OPM RPG or diving into the wonderful world of ILE, there is something there to help.
REFERENCES AND RELATED MATERIALS
AS/400 ILE Concepts V4R1 (SC41-5606-00, CD-ROM QB3AQ700)
ILE RPG for AS/400 Programmers Guide (SC09-2507-01, CD-ROM QB3AGY01)
Interactive Source Debugger (SC09-1897-00, CD-ROM QBKASS00)
Debugger Command ISDB ILE
Display variable contents DSP var or F11 on variable Eval var or F11 on variable Display variable contents in hex DSPHEX var Eval var:x Print variable contents PRT var N/A Print variable contents in hex PRTHEX var N/A
Watch a variable WATCH var WATCH var Watch a variable in hex WATCHHEX N/A Stop Watching a variable UNWATCH Clear watch in Work with
Watches display (WATCH command with no parameters). Change a variable Value CHG var value Eval var=value
Figure 1: This is a list of common commands for both the ISDB and the ILE Debugger.
Debugger Function Key ISDB ILE
Step F5 F10 Run F17 F12 Add/Remove Breakpoint F6 F6 Print variable contents in hex PRTHEX var N/A Watch a variable WATCH var WATCH var Watch a variable in hex WATCHHEX N/A Stop Watching a variable UNWATCH WATCH, then select remove from list Step into N/A F22
Figure 2: Here are common function keys for the ISDB and the ILE Debugger.
Debug Compile Option Meaning
*NONE No debugging is available *STMT Allows debugging using the line numbers or statement numbers of the compile listing.
*SOURCE Provides a source view for debugging the compiled object.
*LIST Provides a listing view for debugging the compiled object.
*COPY Provides a source and copy view for debugging the compiled object. *ALL Provides source, listing, and copy views for debugging the compiled object.
Figure 3: This list shows debug options used when compiling ILE programs.
Release PTF
V3R2 SF46001 V3R6 SF45749 V3R7 SF46327, SF47056 V4R1 SF46327, SF47056 V4R2 SF45191, SF46944, SF47055 V4R3 SF45191, SF46944, SF47055
Figure 4: These are the PTFs needed to enable the *NODEBUGIO options.
LATEST COMMENTS
MC Press Online