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.


MOVE/MOVEL to EVAL


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.


CASEQ to SELECT


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


REMOVAL of GOTO


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 -
http://www.jcrcmds.com 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 http://opensource.org/licenses/gpl-license.html. We can supply the enhanced version of
these programs / source along with any programs and services we provide. Please use our contact page.

If you are uncomfortable doing it yourself we can quote fixed price to do it for you.


Proposed Method Of Conversion


The proposed method of conversion would be to migrate programs to use the Extended Factor 2, which would make the programs much more readable and of course easier to maintain.
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 endeavour to continually enhance the toolset with you, to make this as complete as possible, and of course it will remain open source.


Limitations


Most of the ASSET Generated RPG file I/O makes extensive use of the resulting indicators – the conversion process does not replace these – it is better for the programmer to make use of the BIF's in RPG to convert the error checking to a format that can be migrated to RPG /Free and include additional error checking where relevant.


MOVEL – the majority of MOVEL statements will require at least a cursory evaluation before changing the statement to EVAL just to check the field sizes.


Z-ADD – these statements will not be converted if the field properties are different.


ADD – these statements will not be converted if the field properties are different.


AS/SET uses "DSPLY" as a work field in Display programs – this is a reserved word in RPGIV so must be renamed. A scan and replace in RDi will make short work of this. We have added a program now to do this.

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

KDP Software Limited Tel: +44(0)845 0604123

Ask a question
1000 characters left