Informing the IBM Community

Tutorial: using wizards with RPG and Rational Developer for i


Abstract technology background with hexagonal shapes

I’m going to run through some of the shortcuts/wizards we can employ with RPG using Rational Developer for i (RDi).

Nowadays, it is all about productivity. Gone are the days when we had a DPM (data processing manager) looking over our shoulders to ensure that we were thrashing out code (we didn’t have fancy job titles back then, either). And, having been a programmer for over 32 years, I am all for anything that saves me coding.

For example, if a database uses auto increments on account numbers, it saves me lines of coding. Fantastic.

So what do we have to help us with programming if we are using Rational Developer? By the way, the coding examples shown here are all of the latest free-format type. Rational Developer is great for introducing us to this latest syntax.

The first wizard I am going to show you is how easy it is to code a sub-procedure.


The procedure wizard is very useful for remembering what piece of code to place where – where the PI coding goes, where PR coding goes and so on. To start the wizard, take Source → New → Procedure.
AY Jun Figure 1

As we are going to show you free-form code, ensure you tick the Generate free-form D-spec and P-spec code.

Enter all the details you need for the sub-procedure, including any parameters and return values. Once all details have been input, the code is generated and placed in the correct location within our source. Our prototype and procedure is shown in the figure below.

AY Jun Figure 2

The procedure wizard is a great way to standardise our coding.


With the D-Specification wizard, as you would imagine, we have lots of options for all the various layouts. As with the previous wizard, select Source → New → D-Specification…  This will start the wizard.

In the figure below, we can see all the options that are available.

AY Jun Figure 3

For this example, we are going to generate a data structure to hold our supplier details. Select the D-Specification type of Program described data structure.
AY Jun Figure 4

Once again, the source is generated and inserted where required in our source.

Java Method Call

The features to allow us to call Java objects were introduced in V5R1 of RPG. The wizards can help us enormously in creating the entire necessary source. As with the previous two wizards, select Source → New → Java Method Call …  This will start the Java wizard.

In the example below, we input the package and class details, then the Java method to call.

AY Jun Figure 5

All the procedures and definitions, along with the method call are coded for us.

Code Templates and Context Assist

As their names suggest, these are used to place template code in our C specs.  The advantage of using free-form coding is that the templates can be used throughout your code.

To see all the code templates already provided for us, navigate to Windows → Preferences then navigate as shown in the figure below.

AY Jun Figure 6

If you need to create your own templates, use the New… button to create your own.

How do we use these templates? To include a template in your source, key the template name and press the ctrl-Space key combination. As can be seen below, I coded the SELECT keyword and pressed ctrl-Space then selected the SELECT_OTHER_group template and, voila! the select group template has been included for me.

AY Jun Figure 7

Context Assist

Personally, like many other programmers these days, I do not only code in RPG and the nuances between languages can cause confusion. For example, operational codes for string handling, like substring, that are spelt different in other languages; very annoying. This is where context assist functionality is a very useful.

Context Assist uses the ctrl-Space key combination. In the figure below, it can be seen if I type %SU then the ctrl-Space combination. All the valid operational codes are displayed and you can then drill down to the operational code you need. It will show all the necessary parameters and their order.
AY Jun Figure 8

One of the great features of context assist is that this functionality also works for any procedures that you have created. In the figure below, we can see context assist popping up the details of our GetCustomerDetails procedure.

AY Jun Figure 9

Code snippets

Code snippets are very similar to code templates and can be used to insert standard code into our source without having to open, then copy and paste, from other source members.

Firstly, we have to open the snippets view. This is achieved by selecting Windows → Show View → Other…

AY Jun Figure 10

Then, select General → Snippets

AY Jun Figure 11

We will now see the Snippets View within our workbench.

Unfortunately, there are no RPG snippets predefined for us but they are straightforward to create, so let us create some of our own.
Right-click anywhere in the Snippets view, then select Customize…

AY Jun Figure 12

As we do not want our RPG snippets under the JSP category, let us create a new category called RPG where we can place all our RPG snippets.
AY Jun Figure 13

Now we have an RPG heading, we can create a new item under it. This time, select New → New Item. Enter the source for our snippet and any variables we require.
AY Jun Figure 14

Our Snippets view now has a RPG section and newly created Heading snippet.
AY Jun Figure 15

Double-clicking on it will prompt us for the variables to insert as can be seen in the figure below.
AY Jun Figure 16

I hope that this article will make your RPG coding more productive and help you use these excellent aids supplied by IBM. And if you need help with RPG and RDi, why not take a look at my company’s training courses which can be found here?

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.