.st0{fill:#FFFFFF;}

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

 August 2, 2010

By  NickLitten

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

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

Swap Homes and Travel the World – Join Home Exchange
Surf the Web Securely with OPEN DNS
IBM i Software Change Management – CMS vs ALM – What’s in a Name?
Want to learn CL Programming?
  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Get In Touch

    I’m always looking for awesome input, feedback and critique!

    >

    Snug CBD

     20% Discount

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