24
Tue, Dec
0 New Articles

Advanced Integrated RPG: Providing Solutions to Meet Today's Industry Standards

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

Integrate RPG and Java to take advantage of the latest technologies, such as Excel spreadsheets, Adobe files, and email.

 

Editor's Note: This article is an excerpt from Advanced Integrated RPG, a new MC Press book

 

When you look at your Original Program Model (OPM) programs and think about why these programs were developed, the goal was likely to provide comprehensive software that would withstand the test of time and produce solid, reliable results as the backbone for business-critical operations. If you were to focus solely on this aspect, you might not see the need to even bother using ILE. After all, you have a programming language that works, it has been around for a very long time, and it is easy to understand. So, let's consider some of the limitations of this way of programming and define the reasons why modernization of the code is necessary.

           

The first thing that comes to mind when discussing modernization is aesthetics. When you have a system that provides indisputable data that is necessary for business processes, you may consider the ability to create "modern" reports in Microsoft Excel or Adobe PDF form as being an unnecessary enhancement. After all, the data is being generated, the information is being audited, reporting is being performed, and the company is generating revenue. How important is it to make the reports look better? Well, there are other factors beyond appearance that you need to consider when evaluating the need for spreadsheets and PDF files.

Portability

Portability is a big one. To address this issue, your initial thought might be to generate ASCII text files. If you've been working with RPG for a few years, there's a good chance you've already tried this approach.

           

However, if you delimit the ASCII data using a special character, you must make the user aware of which delimiter you're using, and the user must process the data properly. This means you need specifications that identify what the fields are and how they should be separated. In the end, the data is likely to be imported into an Excel spreadsheet anyway.

           

When you provide ASCII text files, you may have different formats for multiple records in the file. For example, you may have a header that displays a title and possibly user information that does not match the layout of the data, requiring you to identify when record formats change.

           

There is also the issue of delivering the file to the user. Will you use a data transfer that must be defined for each user to download the correct physical file member? Will you use File Transfer Protocol (FTP) and require a user name and password?

           

If you email the text file, its carriage returns and line feeds might be altered during conversion through MIME format. Will you zip the file to avoid this issue, or will your email application embed the text into the email message and force the user to copy and paste the data from there? You could make the data available using a Web server, but if you're going to go that far, you might as well use HTML.

           

The bottom line is that unless you're dealing with another programmer or a power user, you will likely encounter users who resist using ASCII text files, especially given the options available today.

           

PDF files are built specifically to overcome these issues. With PDF files, all that users need is a reader, and they can view any PDF file without any of the preceding concerns. PDF readers are typically free and work on most operating systems. In fact, one is probably already installed with your OS.

           

Even though PDFs are portable, they can be difficult to modify, which can be a good thing or a bad thing, depending on your intentions.

           

Microsoft Excel files offer the same portability as PDF files. Microsoft provides a free viewer that lets users view these files in read-only mode. And with the availability of several open-source options, you can easily create and change such files using software that is supported on most operating systems.

Usability and Standardization

Another reason to provide electronic documents is usability. When you furnish data in an Excel spreadsheet, users can easily search and sort the data, creating ad hoc reports and performing "what if" scenarios. They can also create graphical representations of the data using charts and graphs.

           

Last, Excel and PDF are two of the most commonly used formats. Providing data in these formats makes the work of your users much easier to use and share with others.

Evolving Your RPG Development Skills

In the beginning chapters, we'll explore the evolution of RPG from OPM to ILE and discuss how to exploit the new capabilities of the IBM i platform. Our discussion is structured in a logical direction, first building on your existing RPG coding skills by explaining the new features available in ILE and the new concepts involved with scoping and modular coding practices.

           

We'll start by converting some sample OPM source to an ILE-compatible format and implementing the use of the ILE compilers. With ILE, there are some new concepts to cover that involve the binding of components and the differences between an OPM program and an ILE program. The primary objective of the book is to integrate RPG with Java, so we'll focus our efforts on capabilities that directly lead us to this goal.

           

Once we have the code in an ILE format, we'll begin to discuss procedures, service programs, and activation groups and explain why you may want to use them. For the purposes of the book, we'll look at how you can access Java objects and methods. 

Developing Reusable Code

In our journey toward understanding the use of Java classes and methods from RPG, we will make every effort to encapsulate the Java interface into reusable code. When we do this, I'll go into a detailed analysis of how to interface with the Java environment, and I'll provide some RPG-friendly code that you can use in the future. I call these pieces of code "RPG wrappers" because we'll wrap RPG code around the Java classes and methods.

           

You can make the RPG wrappers available to the program you're working with and use pure RPG code to access the Java functionality. This technique not only makes the code easier for you to use in the future; you can also use it perform all the exception handling so you won't have to repeat the same code.

           

Another benefit to wrapping Java classes and methods in RPG is that you can easily share the new Java capabilities with your fellow RPG programmers in a form that they will be able to use immediately.

Integrating RPG with Java

Enhancing your RPG development skills is a great side effect of the primary objective of this book, which is to exploit the capabilities of Java from within RPG. When we get to this point, we'll explore all the new concepts you need to understand about Java to get it to work properly. It would be nice if you could just plug in a Java method, as you can an API. But there are other things you need to think about when dealing with the Java Virtual Machine (JVM), such as starting and stopping it. And because two totally different environments are communicating with each other, you need to take some extra measures to handle some of the ugliness of reclaiming memory resources.

           

This book will introduce you to the Java components necessary to provide the results you're looking for. It is not intended to teach you Java, but it does introduce you to Java and identify how to use specific parts of open-source technology to provide the product of your hard work, which in this case will be Excel spreadsheets and PDF files that you can distribute using email from RPG.

Creating Electronic Documents

If your objective is to provide reports that can be sorted, graphed, charted, and manipulated, you can convert your greenbar reports into an Excel spreadsheet. We'll do this using the Horrible Spreadsheet Format (HSSF) capability of the POI open-source project.

           

If your intention is to provide documents that can be distributed easily to users and customers in a portable format that anyone on any operating system can use, you may want to convert your greenbar reports, billing invoices, or labels and bar codes to the PDF format. We'll use the iText open-source project to provide these capabilities.

           

We'll accomplish these objectives by first defining the technical terms and concepts of the components that make up an electronic document and then relating them to the classes and methods available in POI and iText. Then, we'll convert the methods and parameters into an RPG-friendly format and build wrappers for them. After that, you can start using them from within RPG.

Distributing Electronic Documents Using Email

When evaluating the options to provide my IBM i system with email capability, I found JavaMail to be the most self-contained and flexible solution. Using JavaMail, we will build an email client that simply creates the email and relays it through your current email server—no additional servers or configuration required. We'll start with a simple text email, specifying the To, From, and Subject, and then advance to formatted emails with HTML and attachments. You can even embed the images right into the email if desired.

           

Using JavaMail for your email client frees you from being tied to the operating system. Once you understand the JavaMail API and you start using Java, you'll be able to easily rewrite your RPG program into pure Java and use the exact same API to provide the same capability to any other server on the network. This freedom and knowledge will also help you as a programmer to begin to integrate with other areas of technology in your company and give you greater flexibility, not only in your programming options but as a valued member of the programming team.

           

And that's just the beginning! In addition to giving you the isolated capabilities of the service programs we'll discuss, I'll walk you through the process of identifying and implementing the classes and methods. So, once you get your RPG programs to start generating electronic documents and sending emails, you can further explore other options that are available and expand your service programs to implement more and more features. I hope this will be the beginning of a whole new level of programming using Java for you. Let's get started.

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: