Bookmark and Share

Recent Posts

Valentines for RPGers

February 15, 2017

Many exciting announcements are going on this week related to IBM i: lots of DB2 for i enhancements, open source goodies, ACS improvements and a new low-end system. You can read more about those in Dawn May's and Steve Will's blogs. 
For those of you who, like us, comb through the announcements looking for something specifically aimed at RPGers, you may have some trouble finding them this time. RPG isn't completely absent from the TR goodies; one of the database enhancements includes a brief mention on dW  that the SQL RPG Pre-compiler will now generate Free Format RPG code, where possible. (We're still trying to imagine where it wouldn't be possible.) 

Hallelujah! Granted we only very rarely actually need to look at the SQL precompiler-generated code, but when we do, it is painful to behold. It isn't just that it is fixed format RPG. It is ancient RPG II-style fixed format code! Since we're starting to get comments from attendees at our RPG & DB2 Summit events that some new RPGers actually can't read or understand the fixed format style of RPG, this is something that will be very helpful for the next generation. Even some of us in the older generations say "Thank you!" to all those at IBM responsible for this gem that we'd almost given up hope of seeing. 
Also some of the ACS enhancements in this week's announcement, such as updates to SQL formatting in Run SQL Scripts and Spool File filtering, will also (we assume) be available via the RDi ACS interface, so these will likely help RPGers who use RDi. 

Now For The "Hidden" RPG Enhancements 

We nearly missed the most significant RPG goodies announced today.  Luckily, just before going live with this blog with a comment that was going to say "what a shame there's not a lot of RPG content here" Barbara Morris' post on the RPG Cafe came out this afternoon to to enlighten us. Since the RPG compiler is not part of the operating system and therefore not part of the TR process, its enhancements are rarely included in the major announcement material. It does however frequently announce new features that are released coincidentally with the TR release and that's true today.
By far our favorite feature in the RPG news of the day is the new support for nested Data Structures. Of course, we've had nested DS for quite a while now. But now, defining them has become much more straightforward. With the advent of the free format declarations and the required "End-DS;" statement, it seemed to be a good idea to allow RPGers to simply code nested structures "directly" rather than requiring the use of separate DS declarations combined with the LikeDS keyword. That's what the new support announced today allows. So instead of coding this: 

dcl-ds  Invoices Qualified;
  InvoiceCount    int(5);
  Invoice Dim(99) LikeDS(Invoice_T);
dcl-ds Invoice_T Template;
  CustomerId      Like(CustNo);
  InvoiceNo       Like(InvNo);
  LineCount       Int(5);
  InvLine Dim(99) LikeDS(InvLine_T);
dcl-ds InvLine_T Template;
    // invoice line details

We will soon be able to code this: 

dcl-ds    Invoices Qualified;
   InvoiceCount    int(5);
   dcl-ds Invoice Dim(99);
      CustomerId   Like(CustNo);
      InvoiceNo    Like(InvNo);
      LineCount    Int(5);
      dcl-ds InvLine Dim(99);
        // invoice line details
This will make coding structures to map XML documents to data structures for use with the XML-Into operation much easier - no longer requiring lots of templates and jumping around to find the "LikeDS" structures. Obviously, this new support only works when using the new free format declarations. 
In addition to the enhanced Nested Data Structure syntax, there are two new built-in functions: %MAX and %MIN. These seem to work much like the similarly named SQL scalar functions. The parameters are a list of values (variables, named constants, hard-coded values, expressions, etc.) to be compared to determine the maximum or minimum value in the list. 
x = %Max( A : B : C)  // If A=1 B=3 C=2, x would = 3

Lastly in the RPG enhancements is the ability to specify ALIGN(*FULL) on a Data Structure. Some years ago RPG added the keyword ALIGN to facilitate interfacing with C functions. However, the action of this keyword didn't completely match the behavior of C in certain cases. While rare, this could cause problems when using C functions such as regex. Specifying ALIGN(*FULL) addresses this issue.  
Check out Barbara's post on the RPG Cafe to read more about these new features. 

Proof That RFEs Work!

All three of these new RPG features came about because some RPGers took the time to request them and many other RPGers took the time to vote for the requests they thought were most valuable. If you have missed our previous posts on the subject, we're talking about online RFEs (Request for Enhancements). At the risk of sounding like a broken record (remember those?), we won't let this opportunity slide by to lobby all of you--once again--to explore the RFEs that your fellow developers have put out there and vote for the ones you think are most important. 
It works and we can personally attest to that. Why? Because that enhancement above that we said was our favorite was submitted by none other than (drum roll, please…) Jon Paris! Many thanks to those who agreed with Jon's suggestion and voted for it. For those who have yet to check out the RFE process, you can find out how to cast your votes, not only for RPG enhancements but also RDi, DB2 for i and many, many other aspects of the IBM i platform. Take a look at one here.

Posted February 15, 2017| Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus