Home > AS/400 Tips > iSeries programmer tips > A guide to the new V5R1 RPG features
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

A guide to the new V5R1 RPG features


Ron Turull
09.10.2001
Rating: -3.84- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This tip is an excerpt from the May 2001 issue of Inside Version 5. It is provided courtesy of The 400 Group.

Take a little bit of C, a pinch of Java, a hint of CL, and a dash of common sense, and you get the new version of RPG that IBM cooked up in V5R1. This latest release is a major improvement. But, of course, I might be a bit biased, since IBM finally "fixed" some of my long-time pet peeves with the language. Nonetheless, I suspect most folks will likewise find the new version of RPG a refreshing change for the better.

Many programmers have a fear of C. To the uninitiated, C's use of symbols like [], ->, **, & and . might make C look cryptic. But believe me, C has a lot to offer, and IBM has steadily realized this over the years and has made many improvements in RPG based on features of the C language.

The latest is the LIKEDS keyword and its requisite qualified data structure subfield names. The LIKEDS keyword allows you to define one data structure based on another data structure. The new LIKEDS keyword is to data structures what the LIKE keyword is to fields. This allows you to create data structure templates. Hooray!

True, I would have liked it much better if IBM had followed C a bit closer and implemented this by allowing programmers to create their own data types (i.e., user-defined data types), but you take what you can get.

No matter how it's done, defining a data structure based on another data structure requires that you can qualify the subfield names. This is done by using the new QUALIFY keyword on the data structure specification. The subfield names will then be qualified with the data structure name and a period as in DS.SF.

In this age of APIs, with their frequent use of complex data structures, these new features are a big plus.

A pinch of Java

Improved Java-RPG interoperability has been a big thing to IBM for some time now. I'm not quite sure the installed base is quite up to that speed, but it sure sounds good in a marketing piece. Any which way, the process is about complete with the latest improvements.

Calls between Java and RPG can now use the Java Native Interface (JNI). You can also now define object-type variables.

The new Object data type allows you to define a variable as an object and the new CLASS keyword allows you to specify which class to use to create the object. Details are still sketchy as to what exactly you will be able to do with objects besides pass them to Java procedures. We'll keep you posted.

A hint of CL

It can hardly be said that CL is a state-of-the-art programming language, but for the most part, it does get the job done. It also has a pretty good exception-handling model. It should, since it closely mirrors the lower-level MI exception-handling model.

The CL exception-handling model allows you to put a "monitor" on a single statement, or on the entire program that will monitor for one or more message IDs. You do this by using a MONMSG command. If one of the messages identified on the MONMSG command is generated, you can branch the program to do whatever type of recovery or message-percolation you want (using the EXEC parameter on the MONMSG command).

Those programmers who appreciate CL's exception-handling devices will be happy to learn that IBM has added a similar model to RPG. True, since the inception of the ILE exception-handling (a.k.a. condition-handling) APIs, you could replicate and even improve upon the CL exception-handling model in RPG. However, with the introduction of three new op-codes -- MONITOR, ON-ERROR, and ENDMON -- in V5R1, you'll be able to do it intrinsically without having to mess with procedure pointers and registering condition-handling procedures.

The MONITOR and ENDMON op-codes are used together (like the IF and ENDIF op-codes) to surround a group executable statements and monitor them for exception. Should one occur, the ON-ERROR op-code is used like the EXEC parameter on the MONMSG command to tell the system what to do. RPG's new exception-handling implementation actually more closely resembles that of MI than CL since MI allows this type of statement group (whereas CL's MONMSG command only lets you monitor the entire program or just a single statement).

RPG makes exception-handling so easy, maybe more programmers might actually do it now. One can hope.

========================
MORE INFORMATION
========================


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries CL programming
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help

iSeries ILE programming
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
How to use the binder language to manage service programs -- Part 2: Understanding the binder language

iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts