TechTalk: Utility to Change all END operations to

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

If you are on OS/400 V2R1, you may already have started to use the new RPG/400 operation codes ENDIF, ENDDO, ENDCS and ENDSL in your programs. You'll find that it doesn't take long to become accustomed to seeing these operation codes in your programs. The first time you go back to do maintenance on a pre-V2R1 program, you'll not be satisfied with the plain old END statement.

So, do you avoid using the new ENDxx statements in the old program to maintain consistency, or do you take the time to manually replace all the END statements in the program? Here's a command that automatically replaces all old END statements in an RPG/400 source member with the appropriate ENDxx statement. It's the Change RPG END Operations (CHGRPGEND) command.

To run the command, key in CHGRPGEND and press F4 to prompt. Key in the source member name and the qualified name of the source file where it resides; then press Enter. The RPG program reads through the C-specs in the selected source member and replaces all END statements with the appropriate ENDIF, ENDDO, ENDCS or ENDSL statement. Up to 99 levels of nesting are supported.

To install CHGRPGEND in your system, simply enter the source code listed in Figures 2 to 4 and compile as indicated at the bottom of each figure.


TechTalk: Utility to Change all END operations to

Figure 2 Command CHGRPGEND

 CHGRPGEND: CMD PROMPT('Change RPG END Operations') PARM KWD(SRCMBR) TYPE(*NAME) LEN(10) MIN(1) + PROMPT('Source member') PARM KWD(SRCFILE) TYPE(Q1) PROMPT('Source file') Q1: QUAL TYPE(*NAME) LEN(10) DFT(QRPGSRC) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library') 
TechTalk: Utility to Change all END operations to

Figure 3 CL program RPG003CL

 RPG003CL: + PGM PARM(&SRCMBR &QSRCF) DCL VAR(&SRCMBR) TYPE(*CHAR) LEN(10) DCL VAR(&QSRCF) TYPE(*CHAR) LEN(20) DCL VAR(&SRCF) TYPE(*CHAR) LEN(10) DCL VAR(&SRCFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(100) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) CHGVAR VAR(&SRCF) VALUE(%SST(&QSRCF 1 10)) CHGVAR VAR(&SRCFLIB) VALUE(%SST(&QSRCF 11 10)) ALCOBJ OBJ((&SRCFLIB/&SRCF *FILE *SHRUPD &SRCMBR)) WAIT(0) OVRDBF FILE(QRPGSRC) TOFILE(&SRCFLIB/&SRCF) MBR(&SRCMBR) + WAITFILE(1) LVLCHK(*NO) SECURE(*YES) CALL PGM(RPG003RG) DLCOBJ OBJ((&SRCFLIB/&SRCF *FILE *SHRUPD &SRCMBR)) RETURN ERROR: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) DLCOBJ OBJ((&SRCFLIB/&SRCF *FILE *SHRUPD &SRCMBR)) MONMSG MSGID(CPF0000) ENDPGM 
TechTalk: Utility to Change all END operations to

Figure 4 RPG program RPG003RG

 FQRPGSRC UP F 92 DISK * E ARY 99 2 * IQRPGSRC NS I 18 19 SPCTYP I 40 41 OPCDE2 I 40 42 OPCDE3 I 40 44 OPCODE * C SPCTYP IFEQ 'C ' C SELEC C OPCDE2 WHEQ 'IF' C ADD 1 X 20 C MOVEL'IF' ARY,X C OPCDE2 WHEQ 'DO' C ADD 1 X C MOVEL'DO' ARY,X C OPCDE3 WHEQ 'CAS' C CASE ANDEQ'N' C ADD 1 X C MOVEL'CS' ARY,X C MOVE 'Y' CASE C OPCODE WHEQ 'SELEC' C ADD 1 X C MOVEL'SL' ARY,X C OPCODE WHEQ 'END ' C OPCODE OREQ 'ENDIF' C OPCODE OREQ 'ENDDO' C OPCODE OREQ 'ENDCS' C OPCODE OREQ 'ENDSL' C OPCODE IFEQ 'END ' C EXCPTCHANGE C ENDIF C ARY,X IFEQ 'CS' C MOVE 'N' CASE C ENDIF C MOVE *BLANK ARY,X C SUB 1 X C ENDSL C ENDIF * C *INZSR BEGSR C MOVE 'N' CASE 1 C ENDSR * OQRPGSRC E CHANGE O ARY,X 44 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: