It is often time consuming to study and analyze a huge RPG program, particularly when it's written by someone else. I've developed a simple utility that summarizes these large programs into a smaller subset that only contains the important statements of the RPG program.
It works by using a Query Management query (*QMQRY) called RPG004QM created from an SQL statement illustrated in 10. The SQL statement extracts what I consider the important statements (main operations such as EXSR, CALL, EXFMT and so forth) from the RPG program. You can easily modify this SQL statement to include any operations that are important to you.
It works by using a Query Management query (*QMQRY) called RPG004QM created from an SQL statement illustrated in Figure 10. The SQL statement extracts what I consider the important statements (main operations such as EXSR, CALL, EXFMT and so forth) from the RPG program. You can easily modify this SQL statement to include any operations that are important to you.
The Analyze RPG Program (ANZ-RPGPGM) command (see 11) allows you to specify a qualified RPG source file, an RPG source member, and the output you desire: display or printer.
The Analyze RPG Program (ANZ-RPGPGM) command (see Figure 11) allows you to specify a qualified RPG source file, an RPG source member, and the output you desire: display or printer.
The command processing program, RPG004CL (see 12), overrides the QRPGSRC file to the file and member you specify. RPG004CL then starts the Query Management query and directs the subset of the RPG program to your display or to the printer depending on the output you specify. 13 contains the output from the ANZRPGPGM command for a typical RPG program. As you can see the program is reduced to a simplified version that can be easily understood.
The command processing program, RPG004CL (see Figure 12), overrides the QRPGSRC file to the file and member you specify. RPG004CL then starts the Query Management query and directs the subset of the RPG program to your display or to the printer depending on the output you specify. Figure 13 contains the output from the ANZRPGPGM command for a typical RPG program. As you can see the program is reduced to a simplified version that can be easily understood.
The ANZRPGPGM Command
Figure 10 The RPG004QM Query Management Query Source
--==================================================================== -- To compile: -- -- CRTQMQRY QMQRY(XXX/RPG004QM) SRCFILE(XXX/QQMQRYSRC) -- --==================================================================== SELECT SRCSEQ, SRCDTA, SRCDAT FROM QRPGSRC WHERE SUBSTR(SRCDTA,28,5) LIKE '%CAS%' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'EXSR ' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'BEGSR' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'ENDSR' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'ENDCS' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'PLIST' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'CALL ' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'PARM ' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'EXFMT' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'WRITE' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'DELET' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA,28,5) = 'EXCPT' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA, 6,1) = 'H' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA, 6,1) = 'F' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA, 6,1) = 'E' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA, 6,1) = 'I' AND SUBSTR(SRCDTA, 7, 1) <> '*' OR SUBSTR(SRCDTA, 6,1) = 'O' AND SUBSTR(SRCDTA, 7, 1) <> '*'
The ANZRPGPGM Command
Figure 11 The ANZRPGPGM Command
/*==================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/ANZRPGPGM) PGM(XXX/RPG004CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*==================================================================*/ CMD PROMPT('Analyze RPG Program') PARM KWD(SRCF) TYPE(Q1) PROMPT('RPG source file') Q1: QUAL TYPE(*NAME) LEN(10) DFT(QRPGSRC) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library') PARM KWD(SRCMBR) TYPE(*NAME) LEN(10) + PROMPT('RPG source member') PARM KWD(OUTPUT) TYPE(*CHAR) LEN(8) RSTD(*YES) + DFT(*) VALUES(* *PRINT) PROMPT('Output')
The ANZRPGPGM Command
Figure 12 RPG Program RPG004CL
/*==================================================================*/ /* To compile: */ /* */ /* */ /* CRTCLPGM PGM(XXX/RPG004CL) SRCFILE(XXX/QCLSRC) */ /* */ /*==================================================================*/ PGM PARM(&RPGQSRC &RPGMBR &OUTPUT) DCL VAR(&RPGQSRC) TYPE(*CHAR) LEN(20) DCL VAR(&RPGSRCF) TYPE(*CHAR) LEN(10) DCL VAR(&RPGSRCLIB) TYPE(*CHAR) LEN(10) DCL VAR(&RPGMBR) TYPE(*CHAR) LEN(10) DCL VAR(&OUTPUT) TYPE(*CHAR) LEN(6) CHGVAR VAR(&RPGSRCF) VALUE(%SST(&RPGQSRC 1 10)) CHGVAR VAR(&RPGSRCLIB) VALUE(%SST(&RPGQSRC 11 10)) OVRDBF FILE(QRPGSRC) TOFILE(&RPGSRCLIB/&RPGSRCF) MBR(&RPGMBR) OVRPRTF FILE(QPQXPRTF) PAGESIZE(*N 132) STRQMQRY QMQRY(RPG004QM) OUTPUT(&OUTPUT) ENDPGM
The ANZRPGPGM Command
Figure 13 Typical Display Output from the ANZRPGPGM Command
SRCSEQ SRCDTA --------- --------------------------------------------------------------- 23.00 C *ENTRY PLIST 24.00 C PARM SQLSTM 27.00 C EXFMTSTMREC 33.00 C *IN61 CASEQ*ON PUP 34.00 C *IN62 CASEQ*ON PDOWN 39.00 C CAS ENTER 40.00 C ENDCS 46.00 C PUP BEGSR 53.00 C ENDSR 54.00 C PDOWN BEGSR 61.00 C ENDSR 62.00 C ENTER BEGSR 68.00 C CALL 'SQL002CL' 50 69.00 C PARM ARS 71.00 C ENDSR
LATEST COMMENTS
MC Press Online