Speeding Up Workflow WIth IBM RDi

IBM RDi can help you work faster. But you can’t just start using it and expect to experience huge increases in productivity. You have to know how to get the most out of this tool.

I use the following “tips” every day to increase my productivity.

The Outline View

Using the outline view allows you to navigate source quickly and accurately. Jump to the start of subroutines by clicking on them, or expand them to find all lines of code with an exsr for that subroutine.

Outline View in RDi

You can do a similar thing with fields: the top level displays the definition of the field, and you can expand it to see all references to the field. Click on each to jump to the corresponding location in the source. You should be using the outline view (read more).

Code Snippets

Do you find yourself writing the same boilerplate code over and over? You probably do, even if you are not consciously aware of it. Ever written a new subroutine? The begsr, endsr and a comment line to describe the subroutine’s purpose are three lines of code already. The subroutine snippet I’ve added to my code snippets comprises eight lines as I’ve included extra blank lines and comments for formatting.

Code Snippets In RDi

That’s eight lines I no longer have to type in manually, or copy from another begsr (once I’ve found one). Read more.

A Record Of Everything I’ve Worked On

In my objects view I’ve created a member filter for every project I’ve worked on since I installed RDi, however small the project. I’ve named each filter very descriptively and specified every source member involved in the project, so if ever I need to remind myself what I did on a particular project last year, I can quickly find out. It’s much quicker than rifling through my often misleading and obstructive notes.

Edit Two Versions Of The Source At The Same Time

Having two versions open of the same source in their own windows is a useful mimic of the SEU F15 browse option. But in RDi you can make changes in both versions! Often I have found myself editing free format code in one window while my other window shows the D specs for reference purposes, and then I’ll make a change to a D spec while I’m there. Changes in one window are reflected in the other window. Using two windows simultaneously like these saves you from jumping around the code erratically in the same window.

In Source Verification

At compilation time In the past, after you have made your changes to a source member in SEU, you will typically have done the following:

  1. F3 to exit
  2. Press Enter to save
  3. Option 14 (or other) to compile the source in PDM
  4. dspmsg to see whether the source compiled successfully
  5. F13 to get rid of the message
  6. Press Enter to return to PDM
  7. Edit the source again, because it somehow failed to compile
  8. F15 to browse the spooled file containing your compile listing
  9. Enter 2 (=Spool file), cursor down to F4 on Browse/copy spool file to find and select the spooled file
  10. Type “B” and press Enter to get to the bottom of the listing
  11. Find an error
  12. Search the listing for the error
  13. After correcting the code, repeat 10 – 13.

Phew, I didn’t realise how many steps I had brainwashed myself with. Admittedly, I can rattle off the above very quickly, but it’s still a lot of unnecessary steps when I could instead use RDi to verify my source for me before a compile, with a fewer keystrokes. All I have to do is press ctrl + v (to verify) and then double click on an error to take me to its place in the code. Read more.

Keyboard Shortcuts

There are many, but these are the ones I use most:

  1. Ctrl + home and ctrl + end to get to top and bottom of the source, respectively. It beats pressing F10, typing “t” and pressing Enter.
  2. Ctrl + d to duplicate a line
  3. Ctrl + backspace to delete a line
  4. F3 on a subprocedure or subroutine to jump to the subprocedure or subroutine
  5. Double on a word to select it for copying, as (opposed to dragging over a word in SEU). In fact, many windowsy shortcuts are available – more RDi keyboard shortcuts


  • Get RDi to close open statements like select, if. Click Window > Preferences > type in “rpg” and find the following:

Automatic Closure Of Control Blocks

Coupling this with the auto indent option above is a big time saver. You type an “if” and press Enter, and you automatically get a matching “endif” with a blank line in between, already indented and ready for you to start typing your code.

IBM RDi Shortcut Of The Day

Imagine you are editing some source in IBM i RDi. You are looking at an exsr statement and you have your cursor positioned on the subroutine name. There are two ways that I know of to jump to the subroutine. The first method involves the following steps:

  1. double click on the subroutine name to select it
  2. copy it with ctrl + v
  3. ctrl + home to get to the top of the source
  4. ctrl + f to open the search box
  5. ctrl + v to paste the subroutine in
  6. escape to close the search box
  7. shift + f4 to repeat find (because there are multiple exsr statements for this subroutine)

That seems like a lot of steps, but they are probably subconscious movements for you by now, after repeated use. If you are anything like me, it takes a matter of seconds to do the above. But what if there are lots of occurrences of the subroutine name (e.g. in comments or multiple exsr statements)? You have to keep pressing F16 until you finally arrive at the subroutine’s begsr. And then of course you risk going past it. Continue reading


The javascript split method splits a string into an array of substrings. Consider the following code:

var string1 = "blue+++green+++yellow+++fuchsia";
var colours = string1.split("+++");

The result is that colours is an array with elements that contain “blue”, “green”, “yellow” and “fuchsia”.

Wouldn’t it be great if there was a split built in function in RPGLE? Sorry, there isn’t. You will have to write your own.

Or copy mine: Continue reading

RPGLE SQL Update A Substring

You are coding an rpgle program. Suppose you have a field that is 20 characters long and you want to update position 5 of it using embedded SQL. I know what you want to do. You want to

update yourFile set substr(field1, 5, 1) = ‘1’ where blah

But you can’t. It’s not allowed.

However, there is a shamefaced workaround that will get the job done: Continue reading

Commenting Source In RDi

I’m talking about commenting your source with references to projects. Each project we undertake is assigned a 5 digit project reference number. Code changes made for a particular project are commented with this reference. The reference number fits conveniently in positions 1 to 5 or the source, whether coding in fixed format or free.

Does this describe the way you annotate your code changes? If so, read on. Continue reading

SQLCODE = -507 SQLSTATE = 24501

You have probably specified that your SQL cursor is for read only, and then tried to update a row in your table using that cursor. If so, just replace the “for read only” bit of your cursor declaration with “for update”. It’s a bit like “update or delete without prior read or chain”.

…or it could be that you have defined multiple cursors for the same file, their use conditioned on different criteria, and you haven’t opened the cursor you are trying to update.


The cursor identified in the update or delete statement is not open. The application program attempted to execute an UPDATE or DELETE WHERE CURRENT OF cursor statement at a time when the specified cursor was not open.

Find In IBM RDi

The Find facility in IBM RDi might seem a little strange if you are coming from a green on black SEU background. In SEU you will type in the search term, press F16 and keep pressing F16 until you find the occurrence of the search term that you want.

In RDi, though, you will press ctrl + f to open up the search box and start typing. Matches are found without having to press F16. Imagine that you have found the first occurrence of the search term in RDi and you want to find the next. In SEU, you would press F16, but doing so in RDi causes weirdness. What you should do instead is either click the Next button (next to the Find box), or close down the Find box and then press F16. Continue reading

Service Entry Points – Green On Black

We have a web application written in RPG. We have written RPG programs that construct the HTML, the finished pages get sent to the browser, and when the user performs an action, page variables are sent back to the server (the IBM i). There is a background job running in batch that processes these requests. If this background job is busy when another request arrives, a new background job is spawned. If there is a lot of activity, it’s not uncommon for a few background jobs to be running at the same time, each serving its own requests. Continue reading