Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Disclaimer: While I was disclosed on these updates prior to announce, I was given the material with a "too late to change anything" timeline. So while I applaud the effort, I would have done some things differently. As I said, unfortunately I wasn't involved earlier enough for it to matter.
IBM today, announced the 5th generation of the Modern RPG Language, although its still called "RPG IV". The new version removes the issues with /FREE and /END-FREE as they are no longer supported. In addition, all H, F D and P specs are free format (fixed-format versions of these specs may be freely intermixed, pun intended) however the legacy I and O specs for program-described data are still required; the compiler detects the I or O in column 6 and behaves accordingly.
Since their doesn't seem to be an official new name for this flavor of RPG, I'm calling it RPGIV+ for simplicity.
COZTOOLS Providing the Solutions for RPG IV and CL development.
We've already written the tools you need in your RPG code so you don't have to.
Featured CL Commands:
Visit: www.cozTools.com
The biggest change you will find in RPGIV+ is the use of the dash or hyphen or minus sign in the opcodes. In fact, everything is now referred to as an OpCode so there's no "D-spec" in RPGIV+ just DCL-xxxx where "DCL-" is the CL style Declare opcode, and xxxx is the object type being declared. Yes, IBM doesn't know how to do "DCL PROC" only "DCL-PROC" so get use to it. In fact, the DCL-xxx opcodes replace the F, D and P specifications.
With this in mind, lets review the new Declare Specifications:
The only other new OpCode is the Header Specification. It is identified as CTL-OPT. So I guess we have to call the Header Spec the "CONTROL OPTIONS" statement. To use it, you specify CTL-OPT followed by a Header specification keyword. People I've spoken with have indicated that they'll be sticking with the H in column 6.
When declaring parameters or subfields there are explicit opcodes available. These opcodes are typically optional, however if a field name is also a classic RPG IV opcode name, then these new DCL-xxx opcodes are required, and they are:
Again, only when the field being declared has an opcode name, like SELECT, CHAIN, WHEN, FOR, etc. then the DCL-SUBF or DCL-PARM opcodes are required. Otherwise the compiler understands that within DCL-PI and END-PI opcodes, all entities are Parameters, and between DCL-DS and END-DS all entities are subfields.
While this is a huge change to the RPG IV language, it is really not a big change once you get your brain around it. Here's a simple example app that accepts one 10-character input parameter and writes a message along with the parameter value to the joblog.
ctl-opt option(*NODEBUGIO:*SRCSTMT) DFTACTGRP(*NO) BNDDIR('COZTOOLS/COZTOOLS'); /include cozTools/qcpysrc,joblog dcl-proc helloRPG; dcl-pi *N; msg char(10); end-pi; joblog('Hello from RPG IV+ %s': %trimR(msg)); end-proc helloRPG;
I suppose we will get used to these changes eventually--but it took 15 years for most RPG programmers to start using free format, so I won't be looking for most programmers to start using this newer stuff any time soon. The good news is, it does work on V7R1 so that may be a reason for earlier adoption than standard free format.
There were some required changes to the language itself. Only a hand full of things have been added, and they are:
RPGIV+ will be taught at conferences and online probably starting this year, as if it were being used in every shop in the world, except yours. Don't worry, it'll be 5 years before people start using it in any volume. So if you want to be an early adopter, go ahead, since it does NOT require V7R2 you won't be eliminating too many systems on which your code can run. I've been using RPGIV+ for a while and it seems to be working fine. There are only two things that continue to bug me when I use this version of RPG:
Neither issue is a show-stopper. The good news is the defaults for the various device types is accurate, therefore you don't really have to use the rather verbose declaratives. The CTL-OPT thing is just going to for us to start spelling CTRL wrong on other systems, or not use it at all, and change the compiler statement defaults instead.
RPGIV+ is the first version of RPG to include a quasi macro language. You can now use the /IF, /ELSE, /ELSEIF, and /ENDIF statements to control how code is generated. I suppose you could always do this, but now you have easier keyword-level control. For example:
dcl-s myDate /if defined( DATE_TODAY ) inz(*SYS) /else inz(*loval) /endif /IF defined(USER_USA) date(*USA) /else date(*ISO) /endif ;
As you can see, while it looks a bit complex, it has become more powerful. And yes, /IF statement may appear anywhere on the line.
RPGIV+ requires statements to appear in column 8 through 80. Column 1 to 5 are still that goofy S/36 comment area, while column 6 may be blank, I or O (or one of the legacy Specs if you want to intermix things). In addition, column 7 may contain the typical / (slash) symbol of a /INCLUDE, /COPY or other directive, but NOT /FREE or /END-FREE as they are no longer used.
The compiler more auto-adjusts to the syntax you use in your code. So there is no separate compiler for this new free format syntax. Just start using it as soon as you get V7.1 TR7 installed or related PTFs.
Look for more information in the IBM V7R1 TR7 Refresh InfoCenter starting October 8, 2013. You can also see a bit more examples that Barbara Morris of IBM Canada, Ltd. has posted in Developerworks. You can download the IBM RPG IV TR7 Reference manual from this link or visit the InfoCenter.
The COZTOOLS ("Cozzi Tools") software product is available at www.cozTools.com Be sure to check out the list of included CL commands and the growing list of examples we provide.
Bob Cozzi is a technical advisor to IBM i clients around the world. His specialty is solving difficult programming issues for his clients, training their programming staffs, and performing system migration/upgrades for small shops. His consulting rates are available online. To contact Bob, send an email to: bob at cozTools.com
You can subscribe to RPG Report (we call it "follow") by visiting the RPG Report page on midrangeNews.com and then click the FOLLOW link in the table of contents for that page. To unsubscribe, simply click that same link. You must be signed up and signed in to midrangeNews.com to start following RPG Report.
I like elimination of /free /end-free, the rest doesn't really do anything for me. I'm on board with going free form, but this syntax seems a bit clunky and for no real gain.