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

IBM i > DEVELOPER > RPG

What's New in V5R4 RPG?


It can be tough keeping pace with the enhancements to the RPG language. Some programs written utilizing the enhancements to the language in the version 5 releases can bear little resemblance to even their version 4 counterparts, much less the RPG/400 programs of old. Version 5 so far has introduced:

  • /Free format calc specs
  • Qualified data names, nested data structures and data structure arrays
  • The ability to monitor for and recover from any kind of program exception
  • Many enhancements making I/O more efficient and less error-prone
  • A wealth of new built-in functions that have simplified and improved efficiency of our code. See our December 2002, June 2004 and October 2004 articles for details.

Those are just the major highlights of the first three releases in version 5. It probably surprises no one that V5R4 brings another round of useful and powerful new features. We wrote an article, slated to appear in the March issue of IBM Systems Magazine, i5 Business Systems edition, with more details of this new release, but we'd like to give you a sneak preview here of the newly announced features.

Certainly the most significant enhancements in this release (at least in terms of number and complexity) relate to the ability to process XML documents directly in RPG programs, but there are a few other gems that shouldn't be overlooked.

Eval Corresponding

Sometimes new support in the language is great as far as it goes, but leaves us realizing that we really could use just a little more help from the compiler. For example, V5R1 and V5R2 gave us the powerful capability to create data structures (DSs) like other DSs or like record formats, thereby duplicating the fields and their attributes. We can even create arrays from those DSs. We use qualified data names to differentiate which version of the subfields of the same name we're using. This support made it easier to define and work with complex structures of data. We exploited some of this capability in the example code in "Sorting it All Out," which sorts subfile data in multiple sequences.

In our example code for that article, the data descriptions for the data destined for the subfile were significantly simplified over what would have been required prior to version 5 because we could tell the compiler to build an array of "records" that look identical to the subfile record:

D    SubfileData       DS                       Qualified
D    SubfileRec                                 LikeRec(ProdSfl:*Output) Dim(99)

The logic to fill the SubfileData structure, however, requires us to move each field one at a time from the database record format to the DS based on the subfile format. This seems overly cumbersome in contrast to the simplicity of the data definition.

// Read all records and fill array of subfile records
DOU %EOF(Product);

      READ ProductR;

      IF Not %Eof(Product);

        n +=1;
        SubfileData.SubfileRec(n).ProdCD = ProdCd;
        SubfileData.SubfileRec(n).ProdDS = ProdDs;
        SubfileData.SubfileRec(n).CatCod = CatCod;
        SubfileData.SubfileRec(n).StOH = StOH;
        SubfileData.SubfileRec(n).SellPr = SellPr;
      ENDIF;

  ENDDO;

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.



Advertisement

Advertisement

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