How Do You Do That with RDi? Part 2: Compile
December 13, 2016 Susan Gantner
In an earlier tip, I began a series on how I do things using RDi that some people seem to prefer doing in PDM. In that first tip, I talked about various ways to copy a source member. In this tip, I’ll talk about compiling with RDi. I must confess to being baffled by the number of people I talk to who, while they do all their editing in RDi, always go back to PDM to do their compiles. To me, if you don’t compile your code with RDi, you’re missing out on a huge time-saver: the ability to do away with perusing compile listings to find the errors. Perhaps those who prefer to do their compiles in PDM just don’t make as many errors as I do! With the Error List view in RDi, I simply double click on any error in the list to be positioned to the relevant line of code in the editor. That saves me a ton of time. Let’s start with the basics. Typically, I’m compiling a program that I’ve just made changes to so it’s in the editor tab in the foreground. From there, I typically use the Compile pull-down menu, at least on the first iteration of a compile for a program. (More in a moment about what I do for later compiles.) From there, I choose either Compile or Compile (Prompt), depending on whether I need to modify any default compile parameters. It’s easy to hit a snag right off the bat when doing that because sometimes the compile options are greyed-out. This is usually because the editor view doesn’t have focus. Perhaps I had been working with the Error List or the Outline views so the focus is now on one of those views. So a simple click back into the editor view (or using the F12 shortcut key) brings the editor back into focus so the compile options are made available. I then select the appropriate compile command from this list and wait for my errors to appear in the Error List. Of course, I’m really hoping all the time to see an empty error list, but if I don’t, I simply double click on each error in the list and fix the problems before my next compile attempt. Once I have made the changes, then on my second (and subsequent) compile attempts I usually use the Ctrl+Shift+C keyboard shortcut since it’s faster than using the menu option. The reason I typically start with the menu option is because the shortcut will repeat the same type of compile command you chose for the last time that type of member. For example, the first time around for an RPGLE source member, I use the menu so that I can be certain of choosing the correct type of compile command; i.e., CRTBNDRPG or CRTRPGMOD or perhaps some special compile command that I’ve created. (More on this later.) On the subsequent compiles, I know it’s OK to simply repeat the last type of compile command until I get a clean compile. If you rarely use different compile types for your source members, you may decide to forego even doing the first compile from the menu and just use the shortcut all the time. A small aside here for a moment about using the Error List view. I mentioned above that I’m hoping for an empty error list. Some of you may have been thinking that the error list will never really be empty because of all the level-00 informational messages that appear there. I never see those messages because I have filtered them out of my Error List view. To do that, look for the “View Menu” icon near the top right corner of your Error List view. (It’s typically the rightmost of the icons there–along with the X and XX to remove the lists–and looks like a tiny inverted pyramid). From the View Menu options, choose “Show Severity” and then de-select the “Information” messages. From now on, you will not see any 00-level messages in your Error List view for any type of compile you do. It’s a much more satisfying feeling to see an empty error list than one where you need to look at the Severity to see if you need to do any more work. One other thing that I like to do with my compile commands in RDi is to customize them. There are two basic ways that I do this. I start by customizing the standard compile commands that come with RDi to set the parameters to the values I prefer. In addition, I sometimes find it useful to create my own special customized compile commands. Some of the parameter customization that I typically do for my RPG compiles includes setting Debug View to *ALL (instead of *Source, which RDi sets by default) and Output(*None). It took me quite a while to wake up to the fact that since I was never going to look at all those compile listings again (I use Error List instead), why should I even create them in the first place? That light bulb finally went on one day as I was doing some mass deletions of old compile listings! As a happy side effect, it seems to me that the compiles run a tad faster as well without the requirement to produce the listing output. To customize the defaults for the standard compile commands, use the “Work With Compile Commands. . .” option from the Compile menu. In the dialog box that pops up, select the CRTBNDRPG and/or CRTRPGMOD command, use the Prompt button and check the “All Parameters” box. Then change the parameters as you see fit–such as for Debugging view and Output and click OK to save those parameter defaults. For some clients, I also need to specify other special parameters for things such as Target Release and the library where the program object should be created. For those situations, I could prompt my compiles to change those but that seems too slow. So when I need some different default parameters for a specific client or application, I create a special version of the compile command with those parameters set appropriately. This begins the same as above with the “Work With Compile Commands. . .” option from the Compile menu. In the dialog box that pops up, I highlight “New command” to create a new one, add a label/name to describe my special command. Then I add the compile command (e.g., CRTBNDRPG) and press the Prompt. . . button. See in the screen shot below an example of the dialog box for creating a custom version of the CRTBNDRPG command. In the prompt for the command, I check the “All Parameters” box and the fill in the parameters that I need for this version of the command, such as the appropriate target release and/or hard-coding the library for the compiled program but also remembering to specify Output(*None) and Debug view (*All) as I do with my own versions of the standard commands. From now on, the Compile menus will show my custom versions of the compile commands for any RPGLE source member type I’m editing – and RDi will also remember that custom compile command for subsequent compiles using the shortcut Ctrl+Shift+C. I’ve often been asked how to see the completion messages following a compile. I do this from the Commands Log view (located in the same area where Error List is). Just page to the bottom of that view to see the completion messages for your compiles. This works well to confirm what command was actually submitted and whether or not the compile was successful. As always, it can be a bit challenging to find errors that occur in the binding step, because the Commands log may only have the completion messages–not the complete job description with messages such as “Definition not found for symbol. . .” or “Binding Directory xxx not found.” The best way to alleviate such challenges is to do your compiles in your RDi host server job rather than submitting them to a separate batch job (which is the default RDi behavior.) When the compile happens in your host server job, those kinds of messages will appear in the Commands log along with the completion messages. To switch the “Compile in batch” behavior, use the Preferences option (under the Window menu), key “Command” into the filter search box near the top left panel of the Preferences dialog. From the filtered list, choose “Command Execution” under Remote Systems → IBM i and then de-select the box for “Compile in batch.” I’m hoping this tip may have helped to convert some of you who may still be compiling in PDM to be able to take advantage of RDi compiles and the valuable Error List that goes with them. Sometimes I hear from people who have more complex requirements for compiling that these tips don’t address. For example, what if you need to do an override before the compile? What if you need to use a completely different compile command from CRTBNDRPG or CRTRPGMOD because of some pre-compile steps or something like that? There are ways to accomplish most of those things in RDi as well. So I will take a look at dealing with more complex compile scenarios in my next tip. Susan Gantner is half of Partner400, a consulting company focused on education on modern programming and database techniques and tools on the IBM i platform. She is also a founding partner in System i Developer, a consortium of System i educators and hosts of the RPG & DB2 Summit conferences. Susan was a programmer for corporations in Atlanta, Georgia, before joining IBM. During her IBM career, she worked in both the Rochester and Toronto labs, providing technical support and education for application developers. Susan left IBM in 1999 to devote more time to teaching and consulting. Together with Jon Paris, she now runs Partner400, and appears regularly at many technical conferences, including System i Developer’s RPG & DB2 Summit. Send your questions or comments for Susan to Ted Holt via the IT Jungle Contact page. RELATED STORY |