August 2

1 comments

CVTRPGSRC – the first step in modernizing RPG3 or RPG400 to modern RPGLE Freeform

By NickLitten

August 2, 2010

#CVTRPGSRC, #ILE, #modernization, #RPG

CVTRPGSRC – Convert RPG Source

This is a standard IBM i command which will ‘Convert RPG Source’ (CVTRPGSRC) from RPG III or RPG/400 source code to ILE RPG source code.

If you are running on a system using the old (1980’s format) RPG source code — easily recognisable because it uses the short column widths and has limitation like 6 character field names — then this is the firs step in code modernization. The CVTRPGSRC command will take the old RPG format and increase it RPGLE format (ten character field names, new opcodes and ability to enter the RPG code in /free format)

Here is a simple program in RPG3:

H****************************************************************H*
H* EXAMPLE RPG3 Program receiving parms, reading file and *
H* returning values in *LDA (JBA/System21 style) *
H****************************************************************
H 1
FCOMPANY IF E K DISK KINFSR 
ILDA E DSLDA
IPSTAT ESDSPSDS
C         EXSR  INIT
C K01     CHAIN COMPANY                    01
C *IN01   IFEQ  *OFF
C         MOVEL VTID01 VTIDPM
C         ELSE
C         MOVEL *ALL'9' VTIDPM
C         END
C         OUT   LDA
C         SETON                            LR
C***************************************************************
C* init subroutine
C*
C***************************************************************
C INIT    BEGSR
C* get the lda
C *NAMVAR DEFN  *LDA      LDA
C         IN    LDA
C* Get the parms
C  *ENTRY PLIST
C         PARM  CONOPM             2
C         PARM  VTIDPM             20
C* Key Fields
C   K01   KLIST
C         KFLD  CONOPM
C ENDSR

So, lets process this using CVTRPGSRC:

CVTRPGSRC FROMFILE(mylib/QRPGSRC)
FROMMBR(RPG3)
TOFILE(mylib/QRPGLESRC)
TOMBR(RPGLE)
LOGFILE(*NONE)

When we run this it generates a new RPGLE version of the code in QRPGLESRC source and it looks like this:

 H****************************************************************
H* EXAMPLE RPG3 Program receiving parms, reading file and *
H* returning values in *LDA (JBA/System21 style) *
H****************************************************************
H DEBUG
FCOMPANY IF E K DISK 
D LDA E DS EXTNAME(LDA)
D PSTAT ESDS EXTNAME(PSDS)
C          EXSR   INIT
C   K01    CHAIN  COMPANY                      01
C   *IN01  IFEQ   *OFF
C          MOVEL  VTID01  VTIDPM
C          ELSE
C          MOVEL  *ALL'9' VTIDPM
C          END
C          OUT    LDA
C          MOVEL  *ON     *INLR
C***************************************************************
C* init subroutine
C*************************************************************** C  INIT    BEGSR
C* get the lda
C  *DTAARA DEFINE *LDA     LDA
C          IN     LDA
C* Get the parms
C  *ENTRY  PLIST
C          PARM   CONOPM    2
C          PARM   VTIDPM    20
C* Key Fields
C  K01     KLIST
C          KFLD   CONOPM
C ENDSR

Note that this doesn’t look too different. We can see that field names are bigger but it still doesn’t convert the OPCODES (operation codes) to the newer format or preferred values. For example, I would prefer to use EVAL for the MOVEL statements.

Watch a realtime RPG modernization example

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

    >

    Snug CBD

     20% Discount

    I have partnered with SNUG CBD givING you Organic CBD
    20% discount code "NL20"