De-commission AS/SET and converting generated code to /FREE - Overview

We have taken Craig Rutledge's RPG conversion tools and enhanced the specifically to convert the generated AS/SET code to/Free format RPG.

The AS/SET generated code is not the prettiest of code, but it works and looks better in free format. We've done this in a number of steps so that it's not just a big bang and each step makes the next easier.  


Re-Structuring The RPG Source

The RPG source generated by AS/SET is restructured in various steps. This is done using open source tools modified by KDP Software.

The modified source is re-compiled during the conversion phase and should be undertaken via the change management process.

Extended Factor 2 conversion

In order to convert to RPG /Free the first step is to convert all programs to make use of the extended factor 2 in the calculation specifications.
During the conversion, the process checks all field attributes and only changes calculations on fields with the same attributes.

Rather than just changing the code it would be more prudent to check both fields to see whether any underlying issues would result in the program not working as expected.

We are testing this element to see if it is prudent to override this restriction.


Example - Before conversion

Example - After conversion

Additionally all program described fields as above are converted to D Specifications and added to the relevant part of the program in alphabetical order.

Once converted to RPG /Free these can then also be converted to Free format.


Example - Before Conversion

Example - After Conversion

Additionally the indicator usage is converted to a more modern format. LR in this example.


IFxx to IF

Ifxx statements are changed to IF using the extended factor two.

Example - Before Conversion

Example - After Conversion


AS/SET generated RPG made extensive use of GOTO which is not supported in RPG /Free so we have upated the open source tools to remove this.

Example - Before Conversion

Example - After Conversion

Convert *entry/call parms to prototypes

Example - Before Conversion


Example - After Conversion

Checking conversion to RPG /Free

Included in the tool set is a command to check what needs to be updated before a program can be successfully migrated to RPG /Free.
This command provides a side-by-side view of the original code and the proposed RPG /Free code.

Any code that is not supported in RPG /Free will be highlighted by ????? as in the example below.

From this example RPG /Free does not use the resulting indicators in the unlock statement – this indicator is not referenced in the code so it can just be removed. If it were referenced in the code then use of the BIF(Built in function) %ERROR can be used to replace any reference to indicator 91 if the code needs to be converted to RPG /Free.

RPG /Free Examples

Finally this is an example of an AS/SET generated RPG display program in RPG /Free – the code is not dissimilar from AS/SET 4GL code and is displayed from Rational 9.0.
This is an example of how the screen processing from a display program is converted. Note the EVAL statements no longer exist at 508 & 514.



Indicator Processing

All settors of indicators where constant '0' or '1' is used to set indicators with either a move for a single indicator or a MOVEA for a number of indicators, has been included so that the converted code conforms to RPG /Free on initial conversion.

Code Before conversion:-


Code After conversion:-

The Conversion Toolset

The conversion toolset is an open source toolset published by Craig Rutledge on his website - it is open source and we have modified certain elements in
order to convert as much of the AS/SET generated code as possible. The source agreement can be found here

Please use our contact page and we will be happy to convert some of your code using our extended version as an example.

You are of course able to visit Craig's page and make your own version. We have tested our version on most of our AS/SET generated code and are able to convert it 100% to free format RPG. 

Proposed Method Of Conversion

The proposed method of conversion would be to migrate programs to RPG4 and use the Extended Factor 2, which would make the programs much more readable and of course easier to maintain. Once these have been tested then the next step would be to convert the code again to Free format RPG.

Alternatively the source could only be upgraded as and when changes are required, we would recommend making sure the latest AS/SET generated source is available before decommissioning AS/SET.

Any programs that then do require maintenance and further testing could be migrated to RPG /Free as a part of this. The additional work to undertake this conversion would be minimal and we will continually enhance the toolset, to make this as complete as possible.

IBM i Security, Tools, development, Change Control and Support 

DISCLAIMER: Please read our terms for the use of this website, if you do not agree to them please do not use our website. If you do use our website you agree to the terms Terms Of Use

Contact Us
1000 characters left