CVTRPGIV is a software utility created to enhance your conversion to RPG IV from earlier RPG versions. It provides easier to read and more native RPG IV source code than the standard conversion utility provided by IBM.

CVTRPGIV has been used to successfully convert thousands of RPG source members with 99.9% accuracy. It can be used on any IBM AS/400 or AS/400 RISC model running OS/400 Release 3, Version 1 or later with ILE RPG/400 installed.

CVTRPGIV is a conversion tool only. No attempt is made to correct or change program logic or deficiencies. Only operations that can be safely converted will be.

Operation codes and new values will be converted to mixed case to highlight changed source statements and expression operations (EQ, NE, GT, LT, GE and LE) will be converted to new RPG IV equivalent expression operators (=, <>, >, <, >=, <=).

CVTRPGIV has the same basic restrictions as IBM's CVTRPGSRC command. The FROM library, file and member (if specified) must exist. The TO library and file must exist and the user must have authority to add members to them. The TO member must not exist. The TO file (default=QRPGLESRC) should be created with a record length of at least 112 instead of the default of 92 or some comments will be lost.

CVTRPGIV converts single, generic* or *ALL source members for a given file source.

CVTRPGIV provides two converstion options: *BASIC and *ADVANCED. *BASIC performs the conversions as detailed on the following pages. *ADVANCED can be utilized to improve code readability with additional conversions. With *ADVANCED, all internal program operation codes (MOVE, ELSE, ENDIF, etc.) are converted to mixed case (Move, Else, Endif, etc.), while external operation codes (CALL, READ, CHAIN, etc.) remain in upper case. Additionally, certain special values (*ON, *OFF, *BLANKS, etc.) are converted to mixed case (*On, *Off, *Blanks, etc.).

It is the user's responsibility to fully test all converted source code before using it in a production environment.

NOTE: When using CVTRPGIV in the demo mode, you will see a message that you are in a 5 minute delay period when converting. When the product is purchased, this function will be disabled.

USING CVTRPGIV

CVTPRGIV may be used interactively or in batch. When performing mass conversions, better performance is usually seen by submitting jobs to batch.

1. To use interactively, enter to following commands.

2. To submit to batch, enter the following command:

The following pages will show examples of the different conversions that CVTRPGIV will perform to your RPG code.

DEFINED CALCULATION FIELDS

CVTRPGIVconverts defined calculations fields to new D specifications.

The following statements would convert from:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CMOVE*ZEROSFLDN692
CMOVE*ZEROSFLDN720
CMOVE*BLANKSFLDA11
CMOVE*ALL'9'FLDN692
C*LIKEDEFNFLDA1FLDA8
To:
DName++++++++++ETDsFrom+++T0/L+++IDc.Keywords++++++++++++++++++++++
Dflda1S1
Dfldn6S92
Dfldn7S20
Dflda8S  Like(FLDA1)
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CMOVE*ZEROSFLDN6
CMOVE*ZEROSFLDN7
CMOVE*BLANKSFLDA1
CMOVE*ALL'9'FLDN6
**************************************

All new D specifications will be sorted alphabetically.

Numeric fields will default to Packed.

Fields defined multiple times (such as FLDN6 above) will only have one D specification statement created.

Calculation specifications with result field lengths will not be deleted, but the length and decimal position values will be removed.

*LIKE/DEFINE calculation statements will be deleted after conversion to D specifications.

IFXX, WHXX AND DOXXX OPERATIONS

The following IFXX statements would convert from:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDA1IFEQFLDA4
CFLDA2OREQFLDA4
CFLDA3OREQFLDA4
CFLDA1IFGTFLDA4
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CIfFLDA1=FLDA4  or
CFLDA2=FLDA4  or
CFLDA3=FLDA4
CIfFLDA1>FLDA4
The following WHXX statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDA1WHEQFLDA2
CFLDA1WHENFLDA2
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CWhenFLDA1=FLDA2
CWhenFLDA1<>FLDA2
The following DOXX statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1DOWGTFLDN2
C*IN99ANDEQ*OFF
CFLDN1DOUEQFLDN2
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CDowFLDN1>FLDA2 and
C*IN99=OFF
CDouFLDN1=FLDN2
**************************************

ARITHMETIC OPERATIONS

The following ADD statements would convert from:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1ADDFLDN3
CADDFLDN3
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=FLDN1 + FLDN2
CEvalFLDN3=FLDN3 + FLDN4
The following SUB statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1SUBFLDN2FLDN3
CSUBFLDN2FLDN3
To:
CL0N01Factor1_++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=FLDN1 - FLDN2
CEvalFLDN3=FLDN3 - FLDN2
The following Z-ADD statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CZ-ADD*ZEROSFLDN3
CZ-ADD999FLDN3
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=*ZEROS
CEvalFLDN3=999
The following Z-SUB statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CZ-SUBFLDN2FLDN3
CZ-SUB1000FLDN3
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=0 - FLDN2
CEvalFLDN3=0 - 1000
The following MULT statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1MULTFLDN2FLDN3
CFLDN1MULT.5FLDN3
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=FLDN1 * FLDN2
CEvalFLDN3=FLDN1 * .5
The following DIV statements would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1DIVFLDN2FLDN3
CFLDN1DIV15FLDN3
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDN3=FLDN1 / FLDN2
CEvalFLDN3=FLDN1 / 15
The EVAL operation has no equivalent to the DIV / MVR operation combination, so any DIV
operation followed by a MVR will not be converted.
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN8DIVFLDN4FLDN6
CMVRFLDN3
Arithmetic operations will not be converted if resulting indicators are present.
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CADDFLDN2FLDN33231
CFLDN4SUBFLDN5FLDN330
*********************************

MOVE/MOVEL OPERATIONS

CVTRPGIV converts MOVE and MOVEL operation codes to Eval operations when *BLANKS or *ZEROS are specified in factor 2.

The following MOVE/MOVEL operations would convert from:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CMOVE*BLANKSFLDA1
CMOVE*ZEROSFLDN1
CMOVE*BLANKSFLDA1
CMOVE*ZEROSFLDN1
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEvalFLDA1=*Blanks
CEvalFLDN1=*Zeros
CEvalFLDA1=*Blanks
CEvalFLDN1=*Zeros
CVTRPGIV converts MOVE and MOVEL operation codes to Eval operations when '1', '0',
*ON or *OFF are specified in factor 2 and the result field is a single indicator.
The following MOVE/MOVEL operations would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CMOVE'1'*IN10
CMOVE'0'*IN11
CMOVE*ON*IN10
CMOVE*OFF*IN11
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEval*IN10=*On
CEval*IN11=*Off
CEval*IN10=*On
CEval*IN11=*Off
MOVE and MOVEL operations will not be converted if resulting indicators are present.
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CMOVEFLDN1FLDN21211
********************************************************

SETON, SETOFF AND COMP OPERATIONS

CVTRPGIV converts SETON, SETOFF and COMP operation codes to Eval operations.

The following SETON satement would convert from:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CSETON1210
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEval*IN12=*On
CEval*IN10=*On
The following SETOFF statement would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CSETOFF2221
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEval*IN22=*Off
CEval*IN20=*Off
The following COMP statement would convert from:
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CFLDN1COMPFLDN2323031
CFLDN1COMPFLDN23232
To:
CL0N01Factor1+++++++Opcode&ExtExtended-factor2+++++++++++++++++++++++++++
CEval *IN32=FLDN1 > FLDN2
CEval*IN30=FLDN1 < FLDN2
CEval*IN31=FLDN1 = FLDN2
CEval*IN32=FLDN1 >= FLDN2
SETON, SETOFF and COMP operations with continuation statements (AN / OR in postions
7 & 8) will not be converted if resulting indicators are present.
CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result++++++++Len++D+HiLoEq
CN50
CAN60SETON1211
C99
COR97FLDN1COMPFLDN2323031
****************************************************

MISCELLANEOUS

CVTRPGIV will not correct any pre-existing problems or ambiguous code. The old adage, "Garbage In, Garbage Out" still applies.

CVTRPGIV can be used on existing RPG IV source members to make use of the above conversion features, but you must be very careful when doing this. RPG IV is still a column oriented lannguage and CVTRPGIV is looking for specific values in specific positions. Caution is advised when using CVTRPGIV on previously converted RPG IV source members if modifications have been made after conversion.

The Eval operation requires the type of expression be the same as the type of the result. Therefore, if *BLANKS were moved into a numeric field, the converted Eval statement will produce a COMPILER error and must be corrected.

The Eval operation is very particular regarding field lengths. When a numeric result is not large enough to contain the expression, a RUNTIME error is produced. If this occurs, either increase the result field size or decrease the field sizes of the Eval expression. If this is not possible, change the Eval statement back to its preconversion value.

Since numeric field definitions default to packed, pay particular attention to any numeric parameters. A RUNTIME error will occur if parameters do not match the calling or called program.

CVTRPGIV performs a statement by statement conversion. You may wish to review your converted source to take full advantage of new features.

For example:

CL0N01Factor1+++++++Opcode&ExtFactor2+++++++Result+++++++++++++++++++++
CEvalFLDN5 = FLDN1 + FLDN2
CEvalFLDN5 = FLDN5 + FLDN3
CEvalFLDN5 = FLDN5 + FLDN4
Could be better expressed by the following:
CEvalFLDN5 = FLDN1 + FLDN24 + FLDN3 + FLDN4
****************************************************

Note: All samples included in this documentation are shown in RPG IV format for easier comparison.