Discover the benefits of using RPG OA and JSON to store metadata in the display file.
Written by Scott Klement
While RPG Open Access is nothing new, there's still some confusion in the IBM i community as to what it is and how it's used. Additionally, there has also been much talk lately about Open Access metadata and how it should be leveraged with regard to RPG application modernization. In this white paper, I'll explain what Rational Open Access for RPG is all about, clarify what metadata is, and cover how metadata is related to Open Access. Then, I'll explain how Profound Logic stores metadata in the Profound UI Rich Display files and why we think it's the best solution for storing metadata.
What Is Rational Open Access?
Rational Open Access for RPG (or "RPG OA" for short) is a feature of the ILE RPG programming language on IBM i 6.1 or higher. It's provided by IBM and was first available in 2010. RPG OA makes it possible to attach a "handler" to an RPG F-spec so that when you use RPG's file opcodes (EXFMT, READ, WRITE, UPDATE, etc.), it will allow the "handler" to take control and handle the output.
In the example in Figure 1, the RPG program uses the EXFMT opcode to display a screen. Without the HANDLER keyword, the RPG compiler would generate code that calls a routine in the operating system, which outputs a 5250 display. But since I added HANDLER, the routine I specified will be called instead (a subprocedure named MYPROC in a service program named MYHANDLER).
That subprocedure can then use any technique it wants to handle the EXFMT code. The code in the handler could, for example, write output to a Web page, a Web service, or even a mobile device.
Figure 1: Simple example of using Open Access
With RPG OA, you can attach handlers to any type of file, including display files, disk files, and printer files.
Figure 2: Using the Profound UI handler
With an existing RPG program, the F-spec is the only line of code you need to change. Once you've added the HANDLER keyword, all of your file operations on that file go through the handler, so the remainder of the RPG code will work exactly as it always has, even though the PROFOUNDUI handler is now writing a beautiful GUI screen for the user to work with. That's all RPG OA does: It adds the handler keyword to the RPG language, letting you replace traditional I/O with a handler. From the user's perspective, it's extremely simple. There's nothing to learn except one new keyword on the F-spec.
What Is Open Access Metadata?
Metadata is the data that the code inside the handler needs to do its job. To illustrate this, consider the DDS code in Figure 3 that was taken from a traditional display file.
Figure 3: DDS snippet taken from a traditional display file
In Figure 3, the RPG file I/O will put fields named *IN30 and PPRICE into a record. When that record is written to the display file, these fields will be written to the display file. How does the display file know it should use the Y keyboard shift? Or the J edit code? And how does it know whether the PR or UL display attribute should be applied to the PPRICE field? It knows that from the DDS keywords, of course! But these DDS keywords are not part of the data that is passed from the RPG program to the handler. Instead, they are stored in the green-screen display file itself. In a traditional green-screen display file, the DDS keywords are the "metadata," the data that the 5250 output routines in the operating system use to understand how to interpret the information provided in the record buffer in order to produce a display.
In a modern rich display, we cannot simply use the DDS keywords such as DSPATR and EDTCDE, keyboard shifts, and so forth. If we did that, our rich displays would be limited to the same features as the legacy 5250 displays are. So we need a more powerful method of storing our metadata, a method that we can extend to add new GUI features without waiting for IBM to add DDS keywords.
Want to Know More?