Bookmark and Share
RSS

Recent Posts

More RPG Language Goodies

October 7, 2014

Sorry we missed writing a blog post last week—we were hard at work filling the brains of the attendees at the RPG & DB2 Summit. One of our guest speakers was IBM’s RPG compiler queen, Barbara Morris, and of course she was asked what enhancements we might expect to see in future updates to RPG. In her customary fashion, Barbara would not give away any secrets, but did tell the questioner that they wouldn’t have long to wait to find out. Yesterday (Monday, Oct. 6) we found out just how true that statement was as Barbara published the outline details of the upcoming enhancements and announced the PTF numbers that implemented them. The PTFs are available for both V7.1 and V7.2 –nice to see the continuation of the trend to make compiler enhancements available on both the current and previous releases.
 
There are two major enhancements to the language—both useful for very different reasons.
 
Longer Field Names:
First you can now specify the ALIAS keyword on any file declaration to have the compiler use the longer SQL names. With the increased usage of SQL to define files, this is a very useful feature, particularly in cases where the creator of the file didn’t think to define system names and so you got stuck with the nasty abbreviated names that the system generates. We have been able to use ALIAS for some time, but only in conjunction with the QUALIFIED keyword and when using Data Structure I/O. This new enhancement brings the longer names in to the realm of traditional RPG I/O without requiring a DS.

As you can see in this simple code snippet, simply by adding the ALIAS keyword, we can now use the long name CUSTOMER_NAME in the RPG code without need for a data structure.
 
  Dcl-F MyTable2 Alias;                
                                        
  Read MyTable2;                       
                                       
  If Customer_Name = *Blanks;          
    Customer_Name = '** Unknown **';   
  EndIf;                               
 
If you look at the compile listing, you can see that the generated I-specs now show the long names. Don’t however take from this that you can code long names in I-specs yourself—this is simply a compiler representation.
 
 3=IMYTABLE2R                                                        
    *-----------------------------------------------------------------
    * RPG record format  . . . . :  MYTABLE2R                        
    * External format  . . . . . :  MYTABLE2R : PARTNER400/MYTABLE2  
    *-----------------------------------------------------------------
 4=I                             A    1   30  CUSTOMER_NAME          
 5=I                             A   31   70  STREET_ADDRESS         
 6=I                             A   71   90  CITY                   
 7=I                             A   91   92  STATE 
 
Relaxed Rules for DS I/O:
The second enhancement concerns the relaxation of the rules for the definition of an externally described, or LIKEREC, DS used for Data Structure I/O. Previously, you had to match the format (*INPUT or *OUTPUT) to the operation being performed. This was particularly frustrating when you knew that the input and output layouts were identical, as is normally the case for disk files, and often caused additional code to have to be written. Under the new rules, any DS defined with type *ALL can be used for all I/O operations on any file type. An additional relaxation also allows the type *ALL parameter to be omitted when using LIKEREC for DISK files. This normally defaults to the *INPUT layout, but as long as the input and output layouts are identical, the compiler will now permit that DS to be used for both input and output operations.
 
Where To Find More Information:
Details have been posted in the RPG Cafe (http://tinyurl.com/Oct2014RPGUpdates), which also lists the PTFs and the links to the announcement. Note that the details have been added to the RPG Reference manual for V7.2 but will apparently not be added to the V7.1 version.
 
Last Thought:
We have to admit that we find it more than a little amusing that these latest enhancements were announced just a week after the latest LinkedIn diatribe concerning the death of IBM i in general and RPG in particular. Strange that so many new features should still be being added to a “dying language.” Perhaps the folks in the Toronto Lab didn’t get the memo? Oh wait … Didn’t Rochester also introduce Node.js to the platform at the same time? Apparently they didn’t get the memo either!
 

Posted October 7, 2014| Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus