Developer > RPG

Developer


Using EGL and RPG Together

RPG - Using EGL and RPG Together

Print Email

In a previous article, "Developing EGL Applications for the System i" (April 2007), I explained the "why" of integrating Enterprise Generation Language (EGL) and RPG. I'm heavily biased in favor of RPG for business rules, especially with the great advances the language has made over the past five or 10 years. (If you think RPG hasn't come a long way, you might want to take a look - it's definitely not your father's RPG.) But one thing RPG lacks is an integrated browser interface. In fact, as RPG progresses it's increasingly becoming a server language, leaving the UI to other players. This article offers three simple steps to take you from business logic to browser without a single line of Java* code.

This article only addresses the screen designer and the capability to create basic records (and perhaps SQL records), which is a relatively small portion of EGL. I'm not even scratching the surface of the vast capabilities of EGL as a true 4GL development environment. The EGL team has made it almost criminally easy to create entire applications from the ground up, with Unified Modeling Language modeling capabilities and SQL schema inspection and auto-generation of code - the list goes on.

But here I want to focus on the features of EGL that make it an extremely powerful browser interface design tool. It's a pretty straightforward process to use EGL as a thin UI layer over your business logic. First, design your server. This is the program that actually performs the business logic. Later in the article I'll go into detail on the design of a server, but for now, let's simply address the communication aspect.

The Strengths of EGL

Basically, two choices for communication are available - simple parameters and structures. The majority of inter-process communications support only simple parameters; every call lets you return only one simple value. For anything but the simplest interactions, it's far easier to use a structure of some kind. Structures exist in nearly every programming language; the RPG term is "data structure." I've used data structures to pass data among RPG programs for nearly as long as I've been programming.

It just so happens that one of EGL's strengths is its ability to handle complex data structures, which it calls records. Using a record as a data structure should be familiar to RPG and COBOL programmers: An externally described data structure is simply a data structure whose layout matches that of a database file. Data structures, both internally and externally described, are excellent vehicles for passing data from one program to another because they let you group a number of fields and handle them all at once.

The problem comes in jumping the divide between IBM* System i* high-level languages (HLL) like COBOL and RPG and the IBM WebSphere* world of Java. Accessing a data structure in Java can be a little tedious. Even with the powerful helper classes in IBM's Toolbox for Java, you still have to write code that defines each of the fields and then associates them in order as a data structure. Once you've done the initial setup, the toolbox's AS400Structure class makes it easier to convert between the extended binary-coded decimal interchange code data used in System i HLL programs and the Java objects used to communicate with browser interfaces. But the initial setup is repetitive and error-prone.

However, with EGL, most of the setup work can be done ahead of time and reused as often as necessary. You can use the EGL capabilities of defining data items and records in DDS-like external files, and then your programming is simply a matter of pointing to those records. You can pass a record to an HLL program, and EGL treats it as a data structure. You can pass a record to a browser page, and EGL does all of the Java data conversions for you. And the browser page designer is powerful because EGL lets you define metadata attributes such as the prompt text, which will automatically be added to the browser page when you drop the record on it. Not only that, but EGL's built-in array handling rivals the ease of use of a subfile.

Let's dispense with the explanation and see the nuts and bolts. I should note that V7 of EGL was recently announced, but since most of you won't yet have the new version, I'm using V6 for this process.

Next page: >>

Page 1 2 3 4

Joe Pluta is the founder and chief architect of Pluta Brothers Design Inc. Joe can be reached at joepluta@plutabrothers.com.

Buyers Guide

Browse products and services for Developer.



Advertisement