|
Here is a CL that I created several years ago. When you compare 2 source files the only printouts that are left are the ones with differences. /* Begin source */ CMPALLSRC: PGM PARM(&NEWFILELIB &OLDFILELIB) DCL VAR(&NEWFILELIB) TYPE(*CHAR) LEN(20) DCL VAR(&OLDFILELIB) TYPE(*CHAR) LEN(20) DCL VAR(&NEWFILE) TYPE(*CHAR) LEN(10) DCL VAR(&NEWLIB) TYPE(*CHAR) LEN(10) DCL VAR(&OLDFILE) TYPE(*CHAR) LEN(10) DCL VAR(&OLDLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(512) DCL VAR(&TYPE) TYPE(*CHAR) LEN(1) DCL VAR(&PREFIX) TYPE(*CHAR) LEN(3) DCLF FILE(OLDMBRS) /* Submit to Batch Queue if Interactive */ RTVJOBA TYPE(&TYPE) IF COND(&TYPE = '1') THEN(DO) SBMJOB CMD(CALL PGM(TS990440C) PARM(&NEWFILELIB + &OLDFILELIB)) JOB(MASSCOMP) JOBQ(QPGMR) RETURN ENDDO /* Break out file names */ CHGVAR VAR(&NEWFILE) VALUE(%SST(&NEWFILELIB 1 10)) CHGVAR VAR(&NEWLIB) VALUE(%SST(&NEWFILELIB 11 10)) CHGVAR VAR(&OLDFILE) VALUE(%SST(&OLDFILELIB 1 10)) CHGVAR VAR(&OLDLIB) VALUE(%SST(&OLDFILELIB 11 10)) CHKOBJ OBJ(&NEWLIB) OBJTYPE(*LIB) CHKOBJ OBJ(&OLDLIB) OBJTYPE(*LIB) CHKOBJ OBJ(&NEWLIB/&NEWFILE) OBJTYPE(*FILE) CHKOBJ OBJ(&OLDLIB/&OLDFILE) OBJTYPE(*FILE) /* Get All Member names from one file / DSPFD FILE(&OLDLIB/&OLDFILE) TYPE(*MBRLIST) + OUTPUT(*OUTFILE) OUTFILE(OLDMBRS) /* Remove all messages */ RMVMSG PGMQ(*SAME) CLEAR(*ALL) LOOP: /* Get member name */ RCVF MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(SKIP)) /* Check existence */ CHKOBJ OBJ(&NEWLIB/&NEWFILE) OBJTYPE(*FILE) + MBR(&MLNAME) MONMSG MSGID(CPF0000) EXEC(DO) RCVMSG PGMQ(*SAME) MSGTYPE(*NEXT) MSGKEY(*TOP) + MSGDTA(&MSGDTA) MSGID(&MSGID) GOTO CMDLBL(LOOP) ENDDO /* Compare source using proper parameters */ IF COND(&MLSEU2 = 'RPGLE' | &MLSEU2 = 'RPGMOD') + THEN(CMPPFM NEWFILE(&NEWLIB/&NEWFILE) + NEWMBR(&MLNAME) OLDFILE(&OLDLIB/&OLDFILE) + OLDMBR(&MLNAME) RPTTYPE(*DETAIL) + OUTPUT(*PRINT) OPTION(*IGNORECASE *WIDE + *RPGLESRCCOL *OMTRPGLECMT)) ELSEIF COND(&MLSEU2 = 'CLLE' | &MLSEU2 = 'CLMOD') + THEN(CMPPFM NEWFILE(&NEWLIB/&NEWFILE) + NEWMBR(&MLNAME) OLDFILE(&OLDLIB/&OLDFILE) + OLDMBR(&MLNAME) RPTTYPE(*DETAIL) + OUTPUT(*PRINT) OPTION(*IGNORECASE *WIDE + *OMTCLCMT)) ELSEIF COND(&MLSEU2 = 'DSPF' | &MLSEU2 = 'PF' | + &MLSEU2 = 'LF' | &MLSEU2 = 'PRTF' | + &MLSEU2 = 'CMD' | &MLSEU2 = 'DSPFCOPY') + THEN(CMPPFM NEWFILE(&NEWLIB/&NEWFILE) + NEWMBR(&MLNAME) OLDFILE(&OLDLIB/&OLDFILE) + OLDMBR(&MLNAME) RPTTYPE(*DETAIL) + OUTPUT(*PRINT) OPTION(*IGNORECASE *WIDE)) ELSEIF COND(&MLSEU2 = 'CLLE' | &MLSEU2 = 'CLMOD') + THEN(CMPPFM NEWFILE(&NEWLIB/&NEWFILE) + NEWMBR(&MLNAME) OLDFILE(&OLDLIB/&OLDFILE) + OLDMBR(&MLNAME) RPTTYPE(*DETAIL) + OUTPUT(*PRINT) OPTION(*IGNORECASE *WIDE + *OMTCLCMT)) ELSEIF COND(&MLSEU2 = 'DSPF' | &MLSEU2 = 'PF' | + &MLSEU2 = 'LF' | &MLSEU2 = 'PRTF' | + &MLSEU2 = 'CMD' | &MLSEU2 = 'DSPFCOPY') + THEN(CMPPFM NEWFILE(&NEWLIB/&NEWFILE) + NEWMBR(&MLNAME) OLDFILE(&OLDLIB/&OLDFILE) + OLDMBR(&MLNAME) RPTTYPE(*DETAIL) + OUTPUT(*PRINT) OPTION(*IGNORECASE *WIDE)) ELSE CMD(DO) CMPPFM NEWFILE(&NEWLIB/&NEWFILE) NEWMBR(&MLNAME) + OLDFILE(&OLDLIB/&OLDFILE) OLDMBR(&MLNAME) + RPTTYPE(*DETAIL) OUTPUT(*PRINT) + OPTION(*IGNORECASE *WIDE) ENDDO /* Check Compare message */ RCVMSG PGMQ(*SAME) MSGTYPE(*NEXT) MSGKEY(*TOP) + MSGDTA(&MSGDTA) MSGID(&MSGID) /* No differences */ IF COND(&MSGID = 'SPC6001') THEN(DO) DLTSPLF FILE(QSYSPRT) SPLNBR(*LAST) RCVMSG PGMQ(*SAME) MSGTYPE(*NEXT) MSGKEY(*TOP) + MSGDTA(&MSGDTA) MSGID(&MSGID) GOTO CMDLBL(LOOP) ENDDO /* There are differences - put member name in user data field */ ELSEIF COND(&MSGID = 'SPC6002') THEN(DO) CHGSPLFA FILE(QSYSPRT) SPLNBR(*LAST) USRDTA(&MLNAME) GOTO CMDLBL(LOOP) ENDDO ELSE CMD(DO) CHGSPLFA FILE(QSYSPRT) SPLNBR(*LAST) USRDTA(&MSGID) RCVMSG PGMQ(*SAME) MSGTYPE(*NEXT) MSGKEY(*TOP) + MSGDTA(&MSGDTA) MSGID(&MSGID) GOTO CMDLBL(LOOP) ENDDO GOTO LOOP SKIP: ENDPGM /* End Source */ I made a few adjustments to the source so there might be some compile errors. Marvin -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of ganeshkumar.murugesan@xxxxxxxxx Sent: Tuesday, May 17, 2005 1:57 AM To: rpg400-l@xxxxxxxxxxxx Subject: RE: compare source file Source file is also a Physical file. You can compare only one member at a time using CMPPFM. I guess you want to compare all the members in a source file. Write a CL program and do a CMPPFM for all the members in the source file. You can do this as follows, * Get all the members in the source file using the command DSPFD FILE (&FILNAM) TYPE (*MBRLIST) and write the result to an outfile. * Read this outfile and execute CMPPFM for each member. Guess this won't take you much time. Thanks, Ganesh -----Original Message----- From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Tomasz Chojecki Sent: Tuesday, May 17, 2005 2:12 PM To: RPG programming on the AS400 / iSeries Subject: compare source file Hello Everyone, Is there any function to compare two source files? I already tried to compare with CMPPFM but its comparing PF File. TIA Załączniki: 1) <none> -- Pozdrowienia/Best Regards, Tomasz Chojecki mailto:tomasz.chojecki@xxxxxxxxxx KIA Motors Polska Sp. z o.o. IT Department Phone No: +48 (prefix) 22 546 40 00 Fax No: +48 (prefix) 22 546 40 40 Web site: http://www.kia.com.pl -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l. Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or Mailadmin@xxxxxxxxx immediately and destroy all copies of this message and any attachments. -- This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/rpg400-l or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.