/* PROGRAM: V89_CL */ /* AUTHOR : Victor Voilevitch */ /* DATE : 15 Nov 1998 */ /* */ /* DESCRIPTION: */ /* Utility program that does */ /* something with each member in physical file */ /* */ /* PARAMETERS: */ /* &LIB - library */ /* &FILE - physical file */ /* &PGM - program that does something with member. */ /* It has parameters (&LIB &FILE &MEMBER &NREC &PERR) */ /* &NREC is number of records in &MEMBER */ /* &PGM returns in &PERR: */ /* '0' if successful complete */ /* '1' if error */ /* &STOP - continue processing ('Y'/'N') if &PGM returned */ /* error (P&ERR='1') for a current member */ /* &PERR - error flag */ /* return '0' if successful complete */ /* '1' if error */ /* '2' if file not exist */ /* '3' if file has no members */ /* '4' if file is in use (locked) */ /* */ /* MONITORED MESSAGES: */ /* CPF0864 End of file detected for file &1 in &2 */ /* CPF3012 File &1 in library &2 not found */ /* CPF9864 Override not found at specified level */ /* CPF1005 Objects not deallocated */ /* */ /* ================================================================= */ PGM PARM(&LIB &FILE &PGM &STOP &PERR) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCL VAR(&PGM) TYPE(*CHAR) LEN(10) DCL VAR(&STOP) TYPE(*CHAR) LEN(1) DCL VAR(&PERR) TYPE(*CHAR) LEN(1) DCLF QSYS/QAFDMBRL /********************************************************************/ /* Start Of Program */ /********************************************************************/ CHGVAR VAR(&PERR) VALUE('0') DSPFD FILE(&LIB/&FILE) TYPE(*MBRLIST) + OUTPUT(*OUTFILE) FILEATR(*PF) + OUTFILE(QTEMP/V89_CL) OUTMBR(&FILE *REPLACE) MONMSG MSGID(CPF3012) EXEC(GOTO CMDLBL(FILENOTEX)) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(FILEERROR)) OVRDBF FILE(QAFDMBRL) TOFILE(QTEMP/V89_CL) + MBR(&FILE) OVRSCOPE(*JOB) SHARE(*YES) DLCOBJ OBJ((&LIB/&FILE *FILE *EXCLRD)) MONMSG MSGID(CPF1005) ALCOBJ OBJ((&LIB/&FILE *FILE *EXCLRD)) MONMSG MSGID(CPF1002) EXEC(GOTO CMDLBL(FILEINUSE)) START: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDOFFILE)) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(FILEERROR)) IF COND(&MLNOMB = 0) THEN(GOTO CMDLBL(FILENOMBR)) CALL PGM(&PGM) PARM(&MLLIB &MLFILE &MLNAME + &MLNRCD &PERR) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(CALLERROR)) IF COND(&PERR = '1') THEN(GOTO CMDLBL(CALLERROR)) GOTO CMDLBL(START) ENDOFFILE: GOTO CMDLBL(END) FILEERROR: CHGVAR VAR(&PERR) VALUE('1') GOTO CMDLBL(END) CALLERROR: CHGVAR VAR(&PERR) VALUE('1') IF COND(&STOP = 'N') THEN(GOTO CMDLBL(START)) GOTO CMDLBL(END) FILENOTEX: CHGVAR VAR(&PERR) VALUE('2') GOTO CMDLBL(END) FILEINUSE: CHGVAR VAR(&PERR) VALUE('4') GOTO CMDLBL(END) FILENOMBR: CHGVAR VAR(&PERR) VALUE('3') GOTO CMDLBL(END) END: DLTOVR FILE(QAFDMBRL) LVL(*JOB) MONMSG MSGID(CPF9841) DLCOBJ OBJ((&LIB/&FILE *FILE *EXCLRD)) MONMSG MSGID(CPF1005) ENDPGM