The good news is that there are a few new nice-to-have features in RPG IV in the next release of OS/400; the bad news is there are a few new features in RPG IV in the next release of OS/400.
It's no secret that I was the leader of the revolt back in the late 1980s and early 1990s to encourage IBM to enhance RPG. After all, at the time, the developers really hadn't done much to the language since it was first announced with the System/38. Today, I am the leader of the apparent lost cause, trying to get IBM to stop enhancing RPG IV on each and every release of OS/400.
I've talked about this before, but I'll summarize my view: By enhancing RPG IV on each release of OS/400 and not making those changes available on previous releases, IBM is fragmenting the RPG development world. Not only do you have to learn the new features, you have to memorize what release of OS/400 they are available on and avoid using features that don't work on your target release. This is leading to widespread confusion in development because people are using features that aren't supported on their release. In my opinion, there is no valid reason that, for example, every new feature in V5R2 should not work in V4R5, or at least V5R1.
No other platform that I know of has the type of restriction that requires you to upgrade the operating system in order to use a new language feature. This is not required under Windows or Linux, for example.
So What's New in V5R2+1 RPG IV?
There are approximately six new features in RPG IV in the next release. One new built-in function, two built-in function enhancements, one parameter enhancement, one database I/O enhancement, and one data type enhancement.
A New Built-in Function
Continuing the theme of the recent %LOOKUP built-in function, the new %SUBARR built-in function allows you to work with a subset of array elements. This is primarily designed to work with dynamically sized arrays. (See my article on this topic.) For example, you can sort a subset of array elements as follows:
D nStart S 5I 0 Inz(13)
D nCount S 5I 0 Inz(12)
C sorta %SUBARR(Sales : nStart : nCount )
In addition to the SORTA opcode, you can use %SUBARR to do a MOVEA-like function with the EVAL opcode. You can also pass the %SUBDUR to the %XFOOT built-in function to sum a subset of the array.
Two Built-in Function Enhancements
The %DEC built-in function will work with date and time variables to more easily convert them into numeric, a much needed feature for compatibility with 8-digit numeric fields in databases that happen to contain date values.
The %TRIMx built-in functions will support an optional second parameter, trim character(s), which will allow you to identify the characters you want to remove from the end of the value. This is the same capability found in the TRIML() and TRIMR() subprocedures in the RPG ToolKit.
Parameter Enhancement
The experienced RPG IV programmer has used syntax similar to the following:
Specifying %TRIMR() for the parameter can be somewhat tedious. A new OPTIONS parameter on the procedure interface and prototype parameters allows you to automatically trim trailing and leading blanks from the parameter value before it is passed.
This capability is only available when the parameter is passed by VALUE or is CONST; it also seems to be supported when passing a C string.
A strange implementation detail is that only OPTIONS(*TRIM) is supported, there is no capability to indicate *TRIML. This seems odd, considering the repetitive warnings from the RPG compiler developers that you should use %TRIMR (trim right end) when you need %TRIMR and not use %TRIM (time both ends) because of performance/overhead. Now, if you choose to use OPTIONS(*TRIM), you have little choice in the matter.
Database I/O Enhancement
The CHAIN, READ, READE, READP, and READPE now support an externally described data structure name in the Result field. This allows you to read a database record into an externally described data structure. If you combine this capability with the PREFIX and/or QUALIFIED keyword, you have a power addition to database I/O.
Data Type Enhancement
With the budget deficit going from a forecast $1.4 trillion surplus just five or six years ago to the largest deficit in history, we may need longer numeric variables. The next release of OS/400 and RPG IV should offer 63-digit packed and zoned decimal variables, including 63 decimal positions. Interestingly, the integer data type has not also been enhanced to support larger integers.
Bittersweet
In all, there are few bits and pieces that make the next release of RPG IV interesting. While I am very happy that IBM continues to enhance and support the RPG IV language, I am disappointed that these features--none of which except the 63-digit numeric are operating system-dependent--must be avoided until you install the next release of OS/400. This sort of makes things anticlimactic.
Bob Cozzi has been programming in RPG since 1978. Since then, he has written many articles and several books, including The Modern RPG Language--the most widely used RPG reference manual in the world. Bob is also a very popular speaker at industry events such as RPG World and is the author of his own Web site and of the RPG ToolKit, an add-on library for RPG IV programmers.
LATEST COMMENTS
MC Press Online