You are currently on IBM Systems Media’s archival website. Click here to view our new website.


When You Wish Upon a Star

Multitasking phone could be your next business breakthrough


Imagine, if you will, that you have control of the RPG compiler for one release cycle. What two features would you choose to implement? This is the question we posed recently to ourselves and a couple of friends, including IBM’s Barbara Morris, who at the end of the day is the person who will oversee the implementation of the new features. Given that even IBM does not have an unlimited budget, we decided that at least one of the choices should be a small nice-to-have feature. For any others, the imagination could run wild.

Jon Paris

Jon’s choice for a “small” feature would be to remove the need for coding /Free and /End-Free. Given that within /Free Calc specs, positions 6 and 7 have to be blank anyway, his feeling is that’s all that should be required. It really irks him to have to remember to code /End-Free before he can start a new subprocedure’s P-spec. Actually, if he’s being honest, he doesn’t actually remember until reminded by the compiler or the RDP verifier, and that’s part of what makes him grumpy.

Actually, Jon has another couple of small features he’d also like to see, rather than one big one. These evolved from his explorations in the world of PHP. One feature he finds really useful is the capability in a PHP function to define a default value for a parameter. For example, a function to calculate state income tax might take amount and the state code as parameters. But if the majority of calculations are being performed for Minnesota, then the first part of the definition might look like this:

function CalcStateTax ( $amount, $stateCode = 'MN') ...

The idea is that if the second parameter isn’t supplied on the call, it’s created and assigned a value of MN. This is much easier than messing with %PARMS and assigning default values based on the result.

Another PHP feature Jon would like to see in RPG (but doesn’t hold out a lot of hope for it happening) is the capability to restrict access to global variables from within subprocedures. In RPG, global variables (i.e., those defined in the main part of the code) are always accessible from within subprocedures. Contrast this with PHP where global variables can only be accessed within functions by explicitly requesting access. For example, in RPG, a global variable named currentUser can be accessed from within any subprocedure. In PHP, to access such a variable would require the programmer to specify Global $currentUser; to request permission to access the variable. The result is that it’s obvious to those reviewing the code later exactly which global variables are being updated by the function.

Aaron Bartell

Our friend Aaron Bartell, whom many will know from his articles for IBM Systems Magazine, has a slightly different notion from Jon of what constitutes small. Aaron would like to see RPG implement procedure overloading (i.e., to allow multiple versions of the same procedure to exist, differentiated by the parameters that they take).

A good example of subprocedure overloading Aaron has found is in the OpenRPGUI project that uses the JSON *SRVPGM object from Mihael Schmidt. Currently, if Aaron needs to have a subprocedure do similar things with various data types he has to create different named subprocedures or introduce awkward use of OPTIONS(*OMIT). For example, if he wanted to create a JSON composer, it’d be great if he could have the following:

json_put('varName': integerVar);
json_put('varName': stringVar);
json_put('varName': booleanVar);

Instead, he must name his subprocedures as follows:

json_putInteger('varName': intVar);
json_putString('varName': stringVar);
json_putBoolean('varName': booleanVar);

Part of the reason for this is that Aaron does a lot of tool/framework development, and procedure overloading is much more of a necessity in that type of development than in developing of more “conventional” business applications, such as Accounts Receivable.

Aaron’s second choice is without a doubt the most frequently requested RPG enhancement—100 percent free form. His reasons are perhaps a little different from many others though. He wants to start marketing RPG to non-IBM i shops. That’s right—he wants to go out and “convert” the great unwashed!

“The cloud computing craze is giving us the perfect opportunity to capitalize on the goodness of RPG plus DB2 plus IBM i,” Aaron says. “I’m starting to incrementally spread the word in nonintrusive ways by posting questions in non-IBM i forums and I always try to mention what my programming stack is.” For example, Aaron just started posting on the Android discussion list at GoogleGroups this week

While we’d like to see a fully free-form RPG, it doesn’t rank as highly on our radar as it does on Aaron’s. The only specs that really annoy us are the F-specs. Totally free-from D-specs would be OK but since the first thing they teach you in any programming class is to play nice and align your definitions, having the D-spec force us to align them really doesn’t phase us that much.

Barbara Morris

IBM’s Barbara Morris also chose completely free-form code as her choice for a big change. For her small change, she picked something that we would have thought was in the big category (but we bow to her knowledge of the compiler and would be delighted to see it happen). Her choice is a way for a procedure to always execute a section of code no matter how it ends. She’d also like to see a way to tell a procedure to reset itself (i.e., close local files, and set up so the next call will have fresh static storage) and perhaps it would even call a specific section of code in the procedure that’s only run for a reset call. We can see a number of interesting uses for this kind of support.

Susan Gantner

Susan is still musing over her choices, and we hope to add to her list the opinions of a few of the other speakers that we had at the RPG & DB2 Summit in Minneapolis last week. Watch our blog for Susan’s updates to this list and join in the conversation. What would you like to see added to the RPG language?


Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.



2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters