From time to time, I need to quickly find out what keys are available on a particular file. I can run the Display File Description (DSPFD) command with the TYPE(*ACCPTH) parameter set. It always takes me a while to sort through all of the information I don't need on that display to find the keys. So, I wrote the Display Key (DSPKEY) utility illustrated in Figures 4 and 5.
The command I wrote uses DSPFD TYPE(*ACCPTH), but the output format is different. A single message that is generated lists all of the keys for a physical or logical file. That message is then displayed so you can easily find out what you need to know.
There are two parts you need to create: the command DSPKEY and the command processing program KEY003CL. I hope you find this utility as useful as I do.
- Avik Dey
TechTalk: DSPKEY Utility.
Figure 4: The DSPKEY Command
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/DSPKEY) PGM(XXX/KEY003CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ CMD PROMPT('Display Key Information') PARM KWD(FILE) TYPE(QUAL) MIN(1) PROMPT('File') QUAL: QUAL TYPE(*NAME) LEN(10) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
TechTalk: DSPKEY Utility.
Figure 5: The KEY003CL Program
/*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/KEY003CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ PGM PARM(&FILLIB) DCL VAR(&FILLIB) TYPE(*CHAR) LEN(20) DCL VAR(&FIL) TYPE(*CHAR) LEN(10) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&KEY) TYPE(*CHAR) LEN(2000) DCL VAR(&FST) TYPE(*LGL) VALUE('1') DCL VAR(&LOOPCNT) TYPE(*DEC) LEN(3 0) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(80) DCLF FILE(QAFDACCP) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) CHGVAR VAR(&FIL) VALUE(%SST(&FILLIB 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&FILLIB 11 10)) DSPFD FILE(&LIB/&FIL) TYPE(*ACCPTH) + OUTPUT(*OUTFILE) FILEATR(*PF *LF) + OUTFILE(QTEMP/KEY003PF) OVRDBF FILE(QAFDACCP) TOFILE(QTEMP/KEY003PF) LOOP: RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ELOOP)) IF COND(&FST *EQ '1') THEN(DO) IF COND(&APNKYF *EQ 0) THEN(GOTO CMDLBL(ELOOP)) CHGVAR VAR(&FST) VALUE('0') CHGVAR VAR(&LOOPCNT) VALUE(&APNKYF) ENDDO ELSE CMD(CHGVAR VAR(&KEY) VALUE(&KEY *TCAT '+')) CHGVAR VAR(&KEY) VALUE(&KEY *TCAT &APKEYF *TCAT '(' + *CAT &APKSEQ *TCAT ')') CHGVAR VAR(&LOOPCNT) VALUE(&LOOPCNT - 1) IF COND(&LOOPCNT *NE 0) THEN(GOTO CMDLBL(LOOP)) ELOOP: IF COND(&FST *EQ '1') THEN(SNDPGMMSG + MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('File + ' *CAT &LIB *TCAT '/' *TCAT &FIL *BCAT + 'is not a keyed file')) ELSE CMD(SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) + MSGDTA('File' *BCAT &LIB *TCAT '/' *TCAT + &FIL *BCAT 'key' *BCAT &KEY)) GOTO CMDLBL(ENDPGM) ERROR: RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM: ENDPGM
LATEST COMMENTS
MC Press Online