TechTalk: DSPKEY Utility.

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: