Feature Dribble Continues for RPG IV with Next Release

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 Sales           S              9P 2 Dim(2000)
    
     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:

     C                   callp     cgiSetVar('CUSTNO' : %trimr(CustName))

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.

BOB COZZI

Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.


MC Press books written by Robert Cozzi available now on the MC Press Bookstore.

RPG TnT RPG TnT
Get this jam-packed resource of quick, easy-to-implement RPG tips!
List Price $65.00

Now On Sale

The Modern RPG IV Language The Modern RPG IV Language
Cozzi on everything RPG! What more could you want?
List Price $99.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: