23
Sat, Nov
1 New Articles

Presenting RPG Subfiles in HTML

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

In the April 2000 issue of Midrange Computing, I wrote an article, entitled “HTML: The New 5250,” in which I showed how HTTP mirrored the 5250 protocol and suggested that HTML could become the new 5250. In that article, I focused on the endpoint of that transition—a JavaServer Page (JSP) that emulates a subfile—but glossed over the details. Well, I’m now going to explain the steps required to get from green to graphical.

Architecture

Emulating a subfile in HTML is another example of the revitalization architecture that I introduced in previous articles. The idea is to replace I/O operations in the original, monolithic RPG program with calls to an API. The API then forwards the requests to an object that emulates a display file (a display file proxy), and, finally, a user interface retrieves the data from the proxy and presents it to the user.

Figure 1 shows the original 5250 protocol. The application program communicates with the device description, which, in turn, exchanges data with the 5250 device. In Figure 2, an intelligent client sits on the workstation and communicates with the display file proxy. This “thick” client has full GUI capabilities and, if written in Java, can be easily ported to any workstation. The primary disadvantage is that an application-specific piece of code must reside on the workstation. Figure 3 (page 84) shows the thin-client option, which uses HTML as the communication vehicle. Any browser can be used on the client, and no application-specific code needs to be kept up to date. The downside is that the interface is limited to HTML, but an HTML-only interface is perfectly capable of supporting subfile emulation.

In both graphical solutions, the client/server APIs communicate with the display file proxy object, so the application client is identical for the two approaches. I’m going to focus on the thin-client solution using the WebSphere Application Server, servlets, and JSPs.

The Logic of Subfiles

To do this, I need first to examine how to program subfiles. There are several different programming techniques, but this article deals with the simplest one, the “fully loaded” subfile. To load and display this type of subfile, follow these steps:


1. Clear the subfile with a WRITE to the subfile control record that has SFLCLR enabled.
2. Loop through your data, writing to the subfile one record at a time.
3. Display the data using an EXFMT to the subfile control record.

Figure 4 shows the data flow of the output cycle. Once the user finishes entering data and presses a command key, the application program reads the data from the subfile using either CHAIN or READC.

The HTML Table

Figures 5 and 6 show an example of the source and output of a simple two-row table with headings. HTML tables are dynamically created from tags. A table consists of a table definition, which consists of row definitions, which, in turn, contain either column headings or data elements. There are many other parameters to a table, and you should use one of the many HTML editing tools to actually create and format the appearance of your table. The tool creates the tags; all you have to do then is fill in the data between the tags.

You may have noticed that the table has only output fields. To make the first cell in the first row input-capable, you replace the data in the first cell with the following HTML input field definition:

Doing this gives you the table shown in Figure 7. Other issues arise when you start talking about input fields. For example, you have to create a form, which associates the input fields with buttons on a Web page. That is outside the scope of this article but is covered in detail in the many excellent HTML books available. You can also learn about creating forms by visiting the World Wide Web Consortium’s Web site at www.w3c.org
.

The JSP Implementation

Finally, you have to get the data from the proxy into the table. The cleanest way to do this is to use a JSP. A JSP is, in essence, a “fill in the blanks” HTML document; the “blanks” are “filled in” by calls to a JavaBean. In the JSP/servlet architecture, the bean is populated by the servlet and passed as a parameter to the JSP. When emulating a subfile, the display file proxy is the JavaBean; it contains all the data that would normally be written to the subfile.

A bit of finesse is needed to define the table. You know the layout of a single row, but you don’t know exactly how many rows are to be displayed. This is where the second feature of JSP, scripting, comes into play. Using “scriptlets,” you code a Java loop right into the HTML that will execute each row. Your display file proxy bean then needs just a couple of methods: one that gets the next row and another that returns the contents of a field in the current row.

Figure 8 shows code that would replace the two hardcoded rows of Figure 4. The getField method must be smart enough to return an HTML input field definition for an input-capable field. The servlet retrieves the data from the fields and updates the subfile when the user submits the page.

Execute Code Reformat

What you’ve just read is a step-by-step process for moving a green-screen subfile to an HTML display with very little change to the original application program. The original program replaces I/O op codes with API calls, and the servlet and display file proxy handle the bulk of the conversation from that point on. Only when an EXFMT op code is emulated does HTML (or, more precisely, the JSP) come into play, and, as you’ve seen, the JSP


coding is really not very difficult. Visit www.java400.net/MC/MC200007index.htm for a complete, working example of an emulated subfile.

Application Program Application Client

AS/400 5250 Device

XXXXXX XXXX XXX XXXX XXX

5250

DEVD Client/

Server APIs

Figure 1: The original 5250 protocol featured a character-mode dumb terminal connected via twinax cabling.

AS/400 Workstation

“Thick Client” UI Server

Display File Proxy

Figure 2: In a typical thick-client solution, business logic resides on a powerful PC, and relational data resides on a host system.


AS/400

WebSphere JavaServer Page

Display File Proxy

Servlet

Workstation

Application Client Client/

Server APIs

xxxx xxxx xxxx

Web Browser

Figure 3: With a thin-client, or browser-based, solution, business logic remains on the host system.

1. WRITE Control (SFLCLR)
3. EXFMT Control

2. Loop WRITE Subfile

XXXXXX XXXX XXX XXXX XXX

Figure 4: The logic required to populate a fully loaded subfile can be done in three basic steps.

<>
<>
<>
<>
Column 1 HeadingColumn 2 Heading
Row 1, Column 1 Data Row 1, Column 2 Data
Row 2, Column 1 Data Row 2, Column 2 Data

 

Figure 5: The new user interface is HTML, and HTML tables effectively replace subfiles.


Presenting_RPG_Subfiles_in_HTML05-00.png 437x141

Figure 6: Even the most basic HTML tables present rows and columns of data with a little more pizzazz than could be mustered with a 5250 subfile.

Presenting_RPG_Subfiles_in_HTML05-01.png 440x140

Figure 7: The cells of HTML tables can be input-capable.


Figure 8: A JSP view bean, such as jdspf, can be used to pull values from rows of a subfile constructed from an RPG application server.


Joe Pluta

Joe Pluta is the founder and chief architect of Pluta Brothers Design, Inc. He has been extending the IBM midrange since the days of the IBM System/3. Joe uses WebSphere extensively, especially as the base for PSC/400, the only product that can move your legacy systems to the Web using simple green-screen commands. He has written several books, including Developing Web 2.0 Applications with EGL for IBM i, E-Deployment: The Fastest Path to the Web, Eclipse: Step by Step, and WDSC: Step by Step. Joe performs onsite mentoring and speaks at user groups around the country. You can reach him at This email address is being protected from spambots. You need JavaScript enabled to view it..


MC Press books written by Joe Pluta available now on the MC Press Bookstore.

Developing Web 2.0 Applications with EGL for IBM i Developing Web 2.0 Applications with EGL for IBM i
Joe Pluta introduces you to EGL Rich UI and IBM’s Rational Developer for the IBM i platform.
List Price $39.95

Now On Sale

WDSC: Step by Step WDSC: Step by Step
Discover incredibly powerful WDSC with this easy-to-understand yet thorough introduction.
List Price $74.95

Now On Sale

Eclipse: Step by Step Eclipse: Step by Step
Quickly get up to speed and productivity using Eclipse.
List Price $59.00

Now On Sale

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: