With the mechanism Derrick Kostiner described (View files fast with PDM and RUNQRY), you have to run WRKOBJPDM command first to view files fast with PDM and RUNQRY. There is a better and quicker way to view file contents quickly. You can achieve it by creating a command (we named it as "Q" for "query"). I am giving the source codes below.
Create this command Q in QGPL with command processing program as "QF";
Q CMD Runqry *none
*************** Beginning of data ******************************************
0001.00 CMD PROMPT('Display File By Query')
0002.00 PARM KWD(FILE) TYPE(QUAL) MIN(1) PROMPT('File')
0004.00 PARM KWD(SELECT) TYPE(*CHAR) LEN(512) DFT(*NO) +
0005.00 SPCVAL((* *YES) (*NO) (*YES)) EXPR(*YES) +
0006.00 CHOICE('*, *NO, *YES') PROMPT('Selection')
0008.00 PARM KWD(KFLD) TYPE(*NAME) LEN(10) DFT(*NONE) +
0009.00 SPCVAL((*NONE)) EXPR(*YES) +
0010.00 PROMPT('Sorting field')
0011.00 PARM KWD(PMT) TYPE(*LGL) DFT(*NO) SPCVAL((* '1') +
0012.00 (*NO '0') (*YES '1')) CHOICE('*, *YES, +
0013.00 *NO') PMTCTL(PMT1) PROMPT('Prompt for +
0014.00 opnqryf')
0015.00 QUAL: QUAL TYPE(*NAME) LEN(10)
0016.00 QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
0017.00 SPCVAL((*LIBL)) PROMPT('Library')
0018.00 QUAL TYPE(*NAME) LEN(10) DFT(*FIRST) +
0019.00 SPCVAL((*FIRST)) PROMPT('Member')
0020.00 PMT1: PMTCTL CTL(SELECT) COND((*NE '*NO'))
0021.00 PMTCTL CTL(SELECT) COND((*NE '*YES'))
****************** End of data ********************************************
Create this program QF in QGPL;
QF CLP CPP for Q (runqry *none)
*************** Beginning of data ********************************************
0001.00 PGM (&FLM &SEL &K1 &PMT)
0002.00 DCL &FLM *CHAR 30
0003.00 DCL &SEL *CHAR 512
0004.00 DCL &K1 *CHAR 10
0005.00 DCL &PMT *LGL
0006.00 DCL &F *CHAR 10
0007.00 DCL &L *CHAR 10
0008.00 DCL &M *CHAR 10
0009.00
0010.00 MONMSG (CPF0000 QRY0000) EXEC(GOTO CMDLBL(ERR))
0011.00
0012.00 CHGVAR &F (%SST(&FLM 1 10))
0013.00 CHGVAR &L (%SST(&FLM 11 10))
0014.00 CHGVAR &M (%SST(&FLM 21 10))
0015.00
0016.00 IF (&SEL *NE '*YES' *AND &SEL *NE '*NO') DO
0017.00 IF &PMT DO
0018.00 ? OPNQRYF FILE((&L/&F &M)) QRYSLT(&SEL) KEYFLD((&K1))
0019.00 ENDDO
0020.00 ELSE CMD(OPNQRYF FILE((&L/&F &M)) QRYSLT(&SEL) +
0021.00 KEYFLD((&K1)))
0022.00 OVRDBF &F SHARE(*YES) OPNSCOPE(*JOB)
0023.00 RUNQRY QRYFILE((&L/&F &M))
0024.00 CLOF OPNID(&F)
0025.00 DLTOVR FILE(&F)
0026.00 RMVMSG CLEAR(*ALL)
0027.00 ENDDO
0028.00
0029.00 ELSE CMD(RUNQRY QRYFILE((&L/&F &M)) RCDSLT(&SEL))
0030.00
0031.00 GOTO END
0032.00
0033.00 ERR: CALL ERRMONC
0034.00 END: ENDPGM
****************** End of data ********************************************
For error monitoring;
Create this program ERRMONC in QGPL;
ERRMONC CLP General error monitor pgm
*************** Beginning of data ************************************************
0001.00 /* GENERAL ERROR HANDLING ROUTINE FOR CL PROGRAMS. */
0002.00 /* TYPICAL USE : */
0003.00 /* PGM */
0004.00 /* DCL .... */
0005.00 /* DCL .... */
0006.00 /* MONMSG CPF0000 EXEC(GOTO ERR) */
0007.00 /* . */
0008.00 /* . */
0009.00 /* . */
0010.00 /* GOTO END */
0011.00 /* ERR:CALL ERRMONC */
0012.00 /* END:ENDPGM */
0013.00 /* */
0014.00 PGM
0015.00 DCL VAR(&LIBPGM) TYPE(*CHAR) LEN(20)
0016.00 DCL VAR(&PGM) TYPE(*CHAR) LEN(10)
0017.00
0018.00 DCL &MSGID *CHAR LEN(7)
0019.00 DCL &MSG *CHAR LEN(512)
0020.00 DCL &MSGDTA *CHAR LEN(512)
0021.00 DCL &MSGF *CHAR LEN(10)
0022.00 DCL &MSGFLIB *CHAR LEN(10)
0023.00 DCL &KEYVAR *CHAR LEN(4)
0024.00 DCL &KEYVAR2 *CHAR LEN(4)
0025.00 DCL &RTNTYPE *CHAR LEN(2)
0026.00
0027.00 CALL PGM(QGPL/RTVINVST) PARM(X'002F' &LIBPGM)
0028.00 CHGVAR VAR(&PGM) VALUE(%SST(&LIBPGM 1 10))
0029.00
0030.00 ERR1: RCVMSG PGMQ(*PRV) MSGTYPE(*EXCP) RMV(*NO) +
0031.00 KEYVAR(&KEYVAR)
0032.00 ERR2: RCVMSG PGMQ(*PRV) MSGTYPE(*PRV) MSGKEY(&KEYVAR) +
0033.00 RMV(*NO) KEYVAR(&KEYVAR2) MSG(&MSG) +
0034.00 MSGDTA(&MSGDTA) MSGID(&MSGID) +
0035.00 RTNTYPE(&RTNTYPE) MSGF(&MSGF) +
0036.00 SNDMSGFLIB(&MSGFLIB)
0037.00 IF COND(&RTNTYPE *NE '02') THEN(GOTO CMDLBL(ERR3))
0038.00 IF COND(&MSGID *NE ' ') THEN(SNDPGMMSG +
0039.00 MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
0040.00 MSGDTA(&MSGDTA) TOPGMQ(*PRV (&PGM)) +
0041.00 MSGTYPE(*DIAG))
0042.00 IF COND(&MSGID *EQ ' ') THEN(SNDPGMMSG +
0043.00 MSGID(USR9999) MSGF(USRMSGF) MSGDTA(&MSG) +
0044.00 TOPGMQ(*PRV (&PGM)) MSGTYPE(*DIAG))
0045.00 RMVMSG PGMQ(*PRV) MSGKEY(&KEYVAR2)
0046.00 ERR3: RCVMSG PGMQ(*PRV) MSGKEY(&KEYVAR) MSGDTA(&MSGDTA) +
0047.00 MSGID(&MSGID) MSGF(&MSGF) +
0048.00 SNDMSGFLIB(&MSGFLIB)
0049.00 SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +
0050.00 MSGDTA(&MSGDTA) TOPGMQ(*PRV (&PGM)) +
0051.00 MSGTYPE(*ESCAPE)
0052.00 END: ENDPGM
****************** End of data ******************************************
Now you can use the command "Q" in some ways;
Q <F4> to get a prompt, Q filename <enter> simplest way to get the file in the first library of your job's library list, Q lib/file <enter> to get a file in a specific library, Q (member/lib/file) <enter> to get a specific member, Q filename * <enter> to get a selection screen, Q filename 'fieldname *EQ "DAVID"' <enter> to give a selection for a character field, Q filename 'fieldname *EQ 1590' <enter> to give a selection for a numeric field, Q filename selection KFLD(fieldname) <enter> to get a sort (you have to make a selection).
=================================
MORE INFORMATION ON THIS TOPIC
=================================
Best Web Links on Systems Management
Share your tips and ideas in our Live Discussion Forums.This was first published in August 2001