This example illustrates how to find queries that accessed a specified file.
GETQRY PGM PARM(&LIBRARY &FILE) DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) DCLF FILE(QTEMP/QRYOBJS) DLTF FILE(QTEMP/QRYOBJS) MONMSG CPF0000 DLTF FILE(QTEMP/&LIBRARY) MONMSG CPF0000 CRTSRCPF FILE(QTEMP/&LIBRARY) DSPOBJD OBJ(&LIBRARY/*ALL) OBJTYPE(*QRYDFN) + DETAIL(*FULL) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QRYOBJS) BEGIN: RCVF /* GET QUERY NAME AND LIBRARY NAME */ /* IF END OF FILE REACHED, EXIT LOOP */ MONMSG CPF0864 EXEC(GOTO EOF) RTVQMQRY QMQRY(&OLDBNM/&ODOBNM) + SRCFILE(QTEMP/&LIBRARY) ALWQRYDFN(*ONLY) GOTO CMDLBL(BEGIN) EOF: FNDSTRPDM STRING(&FILE) FILE(QTEMP/&LIBRARY) MBR(*ALL) OPTION(*NONE) PRTMBRLIST(*YES) ENDPGM
GETQRYPRM PGM PARM(&LIBRARY &FILE) DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10) DCL VAR(&FILE) TYPE(*CHAR) LEN(10) SBMJOB CMD(CALL PGM(GETQRY) PARM(&LIBRARY &FILE)) ENDPGM
Compile program GETQRYPRM.