1. Interactivity

Interactivity is essential to the success of a conversion project. It allows programmers in the legacy and the converted environments to communicate, and application experts to contribute their knowledge of the legacy system.

The RPG converter is an interactive tool. It lets you explore the source code, introduce names, select types, and perform all conversion operations from a graphical user interface.

Relate original and converted code

The RPG converter lets you see the relationships between legacy and converted code. Just navigate either the legacy or the converted source, and see the corresponding element highlighted.

Provide meaningful Java-like names

The first step towards readable and maintainable code is to provide meaningful names. The RPG converter uses its knowledge of RPG and Java naming conventions to provide default names. You can then apply your knowledge of the application domain to improve these names.

RPG names are typically short and cryptic, as in this example:

The first step towards readable converted code is to provide meaningful names. Whenever possible, the RPG converter will provide sensible defaults using COLHDG attribute or comments, these defaults can then be edited.

Here is the same version of the converted code with meaningful names:

Choose appropriate types

In this example, the project default is to convert numeric values with less than 8 digits to Java primitive int, and numeric values with decimal part to java.lang.BigDecimal.

This is how the corresponding operations are converted. The RPG converter inserts type conversions whenever needed.

The default can be overridden. Here for instance, we decide that i04 should also be converted to a BigDecimal.

Note how the generated code changes to take the type modification into account.

2. High-level code patterns

The RPG converter can identify complex code patterns and convert them as a unit.

Consider the following example. By default, each file operation is mapped to the equivalent file operation from a Java library. The resulting code works but is not very Java-like.

We can notice two common patterns in this code. The first pattern iterates over all records in a file:

The second pattern iterates over all records in a file matching the give key:

A possible option is to convert each of these two patterns into a Java for loop. This would lead to the following conversion:

Note how the RPG converter analyzed the klist KEY1 and converted it into a Java condition.

Alternatively, you may decide to store your data in an SQL database, in which case the RPG converter will generate an SQL WHERE clause rather than a Java condition:

It’s even possible to recognize the larger pattern consisting of two embedded loops, and generate the corresponding SQL JOIN query:

The possibilities are endless. You can define the patterns of interest, and specify how they should be converted.

3. Target code architecture

The architecture of the target application is specified using templates.

Whether you prefer to convert your RPG code to a J2EE application using Hibernate for data binding and JSF for screens, or to Java Spring, or to a cloud-native application, or to your own home-grown framework, you can do it by providing the appropriate templates.