13
Wed, Nov
5 New Articles

V6 RPG Swings in on a Thread

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

What are the most significant enhancements to RPG? The answer depends on whom you ask.

 

One of the interesting aspects of the V6R1 release of RPG is that it highlights the differences in perspective between IBM as the language designer and us as the language consumers. Every IBM document I have seen to date places RPG's new multi-threading support front and center, but I have not met many RPG users who were particularly excited by this news. On the other hand, some of the features that receive less emphasis from IBM (for example, increases in maximum sizes) are frequently greeted by cheers from those in the trenches.

 

Undoubtedly, the thread support will become more and more important to us all in the future, but right now it is the byproducts of that support that interest me the most. For example, it seems highly likely that the new support for local files in subprocedures was made possible by changes made for thread support, specifically what is known as the "thread-local static storage" model now available for RPG programs (explanation of that term will have to wait for another day).

 

This will be only a very brief overview of the major features of the new release as I have obviously not had much time to study it in detail and certainly not to try any of these new features out. My teammate Paul Tuohy will be writing more in a couple of weeks.

 

I mentioned changes in size limits at the start, so I'll review those first. For many of us, the size limitations of pre-V6 RPG IV first became a real issue with the introduction of nested data structures in V5R2 and became even more of a problem when those limits severely restricted the utility of V5R4's XML support. Prior to V6, the maximum size of a field or named DS was 65,535 bytes (64K). With V6, that limit rises to 16,773,104 (16Mb), a significant increase. In a similar vein, there is no longer a limit on the maximum number of elements in an array; however, there is a practical limit since the total size of the array cannot exceed the 16Mb storage limit. So the maximum number of elements is now simply a function of how many will "fit." For example, if each array element is 16 bytes long, then the maximum number of elements would be 1,048,319 (16,773,104 / 16).  Similar increases have been made to the length of varying length fields, as well as Graphic and Unicode fields.

 

One other data definition feature that I have been eagerly awaiting is the formal introduction of templates. Ever since LIKEDS was introduced in V5R1, I have been using BASED structures as templates in order to provide a clone-able definition that avoids wasting storage. The problem with this is twofold: First, the compiler will still allow me to erroneously reference fields in the template; and second, a Based structure cannot have initialization values defined for it. The keyword TEMPLATE deals with these problems and can be added to DS or standalone field definitions. Indeed it can even be added to file definitions. (You'll understand why that's useful in a moment.)

 

Speaking of files, I've already mentioned the new support for local files in subprocedures, so let's take a quick look at that. Up until now, all files in RPG programs have been global in nature. They could be used in subprocedures, but the variables that were used were global. This caused many hours of debugging for those who forgot this simple fact, updated a local copy of a file variable in a subprocedure, and couldn't understand why the value on the file was not updated. This situation was eased somewhat in V5R2 when the ability to read into and write from a DS was added. By coding a DS based on the record format (LIKEREC), we were able to avoid some of the problems, but the files remained stubbornly global.

 

V6R1 brings an end to that limit. Files can now be declared within a subprocedure and indeed can even be passed as parameters between subprocedures and programs for that matter. Although subprocedures now support File specs, they do not support Input and Output specs. Consequently, all I/O operations must be performed using DS. Although not yet added to the compiler, this new approach to I/O offers the possibility that long-name support (i.e., alias name support) may arrive in the future since the major barrier to its introduction was the limit on field length imposed by the generated I and O specs.

 

Files within subprocedures are opened automatically and closed when the subprocedure returns to its caller. This allows for true recursive behavior in applications such as Bill of Materials and will significantly simplify coding in such endeavors. Coding the STATIC keyword on the file specification can override this behavior. When this keyword is used, the file remains open and storage is shared between invocations.

 

How do we pass a file as a parameter? Simple: just use the LIKEFILE( ) keyword to define the parameter in the prototype. Note that if you want to directly access the file's variables, you must also pass the I/O DS as a parameter. Under the covers, the compiler is able to access any variables associated with the file that it needs (e.g., the INFDS, the EXTFILE variable, etc.), but you must make your own arrangements to access the data. I think we are going to be seeing a lot of uses for this new capability, but there will also be a number of folks who have performance problems because they didn't think about the impact of the frequent file open/close activity.

 

I won't say too much more or Paul will have nothing to write about, but I will just briefly mention some of the other highlights:

 

•·        The compiler now performs implicit conversion between character and UCS-2 (Unicode) variables. This may not seem very important to you today, but as you do more XML work, you will find it considerably simplifies your life.

•·        You now have the ability to use DS I/O with EXFMT by adding the qualifier *ALL to the LIKEREC or EXTNAME DS keywords.

•·        The file keyword EXTDESC has been added to allow you to specify the file definition to be used by the compiler when EXTFILE is used so that you can avoid "file definition not found" at compile time problems.

•·        Support for removing unused variables from the compiled program reduces static storage occupancy.

•·      There are also a number of other, smaller related updates, but these are the big hitters in the release.

 

Did I forget anything? Oh yes, I would be remiss if I didn't at least mention that the keyword THREAD(*CONCURRENT) can be used on the H-spec to allow the module to be able to run concurrently in multiple threads or to allow multiple threads to run in the module. As I noted earlier, this is going to become more important in the future. For now, it is only really of interest to those of you who build mixed Java and RPG applications.  

Jon Paris

Jon Paris's IBM midrange career started when he fell in love with the System/38 while working as a consultant. This love affair ultimately led him to joining IBM.

 

In 1987, Jon was hired by the IBM Toronto Laboratory to work on the S/36 and S/38 COBOL compilers. Subsequently, Jon became involved with the AS/400 and in particular COBOL/400.

 

In early 1989, Jon was transferred to the Languages Architecture and Planning Group, with particular responsibility for the COBOL and RPG languages. There, he played a major role in the definition of the new RPG IV language and in promoting its use with IBM Business Partners and users. He was also heavily involved in producing educational and other support materials and services related to other AS/400 programming languages and development tools, such as CODE/400 and VisualAge for RPG.

 

Jon left IBM in 1998 to focus on developing and delivering education focused on enhancing AS/400 and iSeries application development skills.

 

Jon is a frequent speaker at user group meetings and conferences around the world, and he holds a number of speaker excellence awards from COMMON.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • 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.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • 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

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • 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: