A C++ and Java Conversion Tool for RPG

Article ID: 18151

It's getting to be a classic dilemma in iSeries environments: you want to migrate applications to Java to put them on the Web, but it's complicated because the apps are written in various flavors of RPG. You could rewrite all that software in Java or C++ and improve some functions along the way, but the return on investment is going to be a loser. And what about new applications? You could write them in Java or C++ if you know those languages, but if you don't, you have to add a learning curve to any project that uses them. If you want to modernize your iSeries development, you need a fresh approach.

Advanced Systems Concepts, Inc.'s (ASC's) RPG Into Objects (RIO) is one solution. It's a software tool that automatically converts RPG into Java classes or C++ programs, and the converted code runs on any platform that supports either language. The goal of RIO's designers is to translate RPG into Java or C++ code that resembles RPG syntax and style. Translated variable names are lowercase equivalents of their RPG names, for example. Also, RIO-generated code uses the same function names and parameters as the original source.

Not to be confused with a Web-facing or GUI conversion tool, RIO translates RPG business logic into Java or C++ and provides a Web front end for new applications. It's also tightly integrated with IBM's WebFacing tool, which converts display files into Java Server Pages (JSPs).

RIO's latest release adds support for eXtensible Markup Language (XML). This support lets developers expose just the data from display screens (Figure 1). Programmers can use this data as a Web service or add multiple screens of data to a Web page.

Handling RPG's Peculiarities

RIO generates C++ programs and Java classes without requiring a proprietary 4GL to maintain the new source. In fact, programmers can use any development tool or environment they want for source modification and maintenance. RIO also includes C++ and Java templates that simulate RPG functions that aren't native to C++ or Java and lets developers migrate RPG code into those templates. An important point is that RIO generates source code rather than byte code, so the C++ programs that RIO produces don't use a runtime system and have to be recompiled on the platform on which they're intended to execute.

On average, RIO can convert a 5,000-line RPG program in a few minutes. RIO can translate approximately 90 percent of RPG source into either Java or C++, including most RPG II source. RIO also translates 60 to 80 percent of CL programs, including CL program construction commands (e.g., IF, ELSE, DO, CALL, CHGVAR), statement-level (but not global) MONMSG commands, most GOTO statements, and some other system commands. In addition, RIO moves comments from RPG source into the new source file in either language and turns embedded SQL into SQLJ statements, which is the embedded SQL standard for Java.

Programs converted to C++ continue to work with 5250 screens, although code converted to Java requires IBM's WebFacing tool to convert display files into JSPs that work with RIO-generated code. This lets developers use RPG application logic without having to separate the user interface and business code.

Service programs convert a little differently. Each module of a service program becomes its own class when converted to Java, resulting in RIO .class files, each of which the JVM loads dynamically as needed. During Java translations, RIO automatically converts many GOTO and CABxx statements but marks those that it can't convert as errors, for example when a GOTO jumps from a subroutine into main-line RPG code.

Simple Application Conversion

Converting an application with RIO essentially consists of three steps: loading files into the RIO cross-reference, translating the RPG source, and compiling the translated source. The developer tells RIO what to convert and the type of output needed, and the rest is done automatically.

RIO's cross-reference database holds basic data about files, fields, and programs and is a subset of ASC's ABSTRACT impact analysis product. RIO uses this information source to help create header files that map program output to developer-created classes.

If part of a project requires moving all or part of an application off the iSeries, perhaps the biggest issue is keyed database access. RIO-converted Java code using record-level access running against another database can create performance issues, depending on the Java Database Connectivity (JDBC) support for the target database. ASC has overcome some of these issues with caching technology that lessens the impact of data lookups by the translated applications. Applications built on SQL will likely have fewer such issues.

A side benefit is that RIO can function as a Java or C++ learning tool. Simply studying converted code shows developers how to structure RPG-like logic in either of the other languages for other projects.

According to a recent Gartner Group study, it costs between $4 and $6 per code line to transform procedural languages such as RPG to Java. If your plans call for converting applications to Java to gain greater Web exposure, or to convert to C++ to reap performance benefits, ASC's RIO is worth consideration.

John Ghrist is senior products editor for iSeries NEWS.


Vendor Contact Information

Advanced Systems Concepts, Inc.
(847) 605-1311
Fax (847) 605-1912
asc-iseries.com
RPG Into Objects (RIO)

Prerequisites:
For V4R4 or V4R5 C++: IBM option 13 System Openness Includes (5769SS1) and IBM ILE C++ for AS/400 (5799GDW). For V4R4 or V4R5 Java: IBM products AS/400 Toolbox for Java (576JC1) and AS/400 Developer Kit for Java (5769JV1).

For V5Rx C++: IBM option 13 System Openness Includes (5722SS1), option 33 PASE for TGTRLS support (5722SS1), option 52 and option 54 ILE C++ compiler/*PRV support (5722WDS).

For V5Rx Java: AS/400 Toolbox for Java (5722JC1) and AS/400 Developer Kit for Java (572JV1).

For Java ServerPage results, in addition to the above requirements: WebSphere Development Studio Client for iSeries WebFacing client version 4.01 or higher and an application server that supports JSP 1.0 and UTF-8 (e.g., WebSphere, Tomcat).

For use with databases other than DB2/400, in addition to the above requirements: a JDBC 2.0 driver and one of: 1) a JDBC-accessible database that supports updatable results sets via an SQL statement containing an ORDER BY clause, 2) a JDBC-accessible database that supports a ROWID-like function, or 3) the ability to specify a unique identifier in each accessed table.

Price: Consult vendor

ProVIP Sponsors

ProVIP Sponsors