If your data queues are growing out of control, here's a utility to automatically shrink them to minimum size.
Reclaiming disk space is so vital that most of us go out of our way to recover every byte we consider wasted. If you implement data queues in your system, be aware that they have a tendency to grow in size and will never shrink of their own accord.
IBM recommends that you delete and re-create your data queues periodically, but they don't make it easy for you. There's no Display Data Queue Description (DSPDTAQD) command to see if an existing data queue is *FIFO, *LIFO or *KEYED, or to see any of the other attributes. How, then, can you re-create an existing data queue?
V2R1 added an API that solves the problem. The trouble is that, like all APIs, it's cumbersome to use. Worse, it has a name that I'm sure you will never remember: QMHQRDQD. This API returns binary information, which means that you can't use it in a CL program. It's one obstacle after another.
To make things easier for you, I created the Reorganize Data Queue (RGZDTAQ) command, 1a and its accompanying programs DTAQ005CL (1b) and DTAQ005RG (1c). It uses the QMHQRDQD API to retrieve the data queue attributes, deletes the data queue, and creates it again with the same owner and user authorities it had before. The comments in the code should help you to understand how this utility works.
To make things easier for you, I created the Reorganize Data Queue (RGZDTAQ) command, Figure 1a and its accompanying programs DTAQ005CL (Figure 1b) and DTAQ005RG (Figure 1c). It uses the QMHQRDQD API to retrieve the data queue attributes, deletes the data queue, and creates it again with the same owner and user authorities it had before. The comments in the code should help you to understand how this utility works.
RGZDTAQ has only one parameter: DTAQ (qualified name of the data queue to be re-created). The only prerequisite is the QUSRTOOL, CHKAPOST, which you must create before compiling CL program DTAQ005CL. See page 50 for instructions to create user tools from QUSRTOOL.
Now you can reorganize your data queues periodically and save valuable disk space.
Reorganize Your Data Queues
Figure 1A Command RGZDTAQ
RGZDTAQ: CMD PROMPT('Reorganize Data Queue') PARM KWD(DTAQ) TYPE(Q1) MIN(1) PROMPT('Data queue') Q1: QUAL TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) EXPR(*YES) PROMPT('Library')
Reorganize Your Data Queues
Figure 1B CL program DTAQ005CL
DTAQ005CL: + PGM PARM(&QDTAQ) DCLF FILE(QAOBJAUT) DCL VAR(&CMD) TYPE(*CHAR) LEN(256) DCL VAR(&DTAQ) TYPE(*CHAR) LEN(10) DCL VAR(&DTAQLIB) TYPE(*CHAR) LEN(10) DCL VAR(&FORCE) TYPE(*CHAR) LEN(10) DCL VAR(&KEYLEN) TYPE(*DEC) LEN(3 0) DCL VAR(&KEYLEN_C) TYPE(*CHAR) LEN(3) DCL VAR(&MAXLEN) TYPE(*DEC) LEN(5 0) DCL VAR(&MAXLEN_C) TYPE(*CHAR) LEN(5) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(132) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&OWNER) TYPE(*CHAR) LEN(10) DCL VAR(&QDTAQ) TYPE(*CHAR) LEN(20) DCL VAR(&RTNTEXT) TYPE(*CHAR) LEN(500) DCL VAR(&SENDERID) TYPE(*CHAR) LEN(4) DCL VAR(&SEQ) TYPE(*CHAR) LEN(6) DCL VAR(&TEXT) TYPE(*CHAR) LEN(50) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) /* Break qualified data queue name and validate it */ CHGVAR VAR(&DTAQ) VALUE(%SST(&QDTAQ 1 10)) CHGVAR VAR(&DTAQLIB) VALUE(%SST(&QDTAQ 11 10)) CHKOBJ OBJ(&DTAQLIB/&DTAQ) OBJTYPE(*DTAQ) /* To retrieve the data queue description, we call program + DTAQ005RG which in turn calls API QMHQRDQD. Then retrieve + the owner name with the RTVOBJD command, and get all user + authorities with the DSPOBJAUT command */ CALL PGM(DTAQ005RG) PARM(&QDTAQ &MAXLEN &SEQ &KEYLEN &TEXT + &FORCE &SENDERID) RTVOBJD OBJ(&DTAQLIB/&DTAQ) OBJTYPE(*DTAQ) OWNER(&OWNER) DSPOBJAUT OBJ(&DTAQLIB/&DTAQ) OBJTYPE(*DTAQ) OUTPUT(*OUTFILE) + OUTFILE(QTEMP/QAOBJAUT) OUTMBR(*FIRST *REPLACE) OVRDBF FILE(QAOBJAUT) TOFILE(QTEMP/QAOBJAUT) /* Build the CRTDTAQ command string. We splice together most of + the pieces of information we have about the data queue */ CHGVAR VAR(&MAXLEN_C) VALUE(&MAXLEN) CHGVAR VAR(&KEYLEN_C) VALUE(&KEYLEN) TAATOOL/CHKAPOST VAR(&TEXT) RTNVAR(&RTNTEXT) /* DOUBLE EMBEDDED + QUOTES */ CHGVAR VAR(&TEXT) VALUE(%SST(&RTNTEXT 1 50)) CHGVAR VAR(&CMD) VALUE('CRTDTAQ DTAQ(' *CAT &DTAQLIB *TCAT '/' + *CAT &DTAQ *TCAT ') MAXLEN(' *CAT &MAXLEN_C *CAT ') SEQ(' + *CAT &SEQ *TCAT ') TEXT(''' *CAT &TEXT *TCAT ''') FORCE(' + *CAT &FORCE *TCAT ') SENDERID(' *CAT &SENDERID *TCAT ')') IF COND(&KEYLEN *GT 0) THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + 'KEYLEN(' *CAT &KEYLEN_C *CAT ')')) /* Delete and recreate data queue */ ALCOBJ OBJ((&DTAQLIB/&DTAQ *DTAQ *EXCL)) WAIT(0) DLTDTAQ DTAQ(&DTAQLIB/&DTAQ) DLCOBJ OBJ((&DTAQLIB/&DTAQ *DTAQ *EXCL)) MONMSG MSGID(CPF0000) CALL PGM(QCMDEXC) PARM(&CMD 256) /* EXECUTE CRTDTAQ COMMAND */ CHGOBJOWN OBJ(&DTAQLIB/&DTAQ) OBJTYPE(*DTAQ) NEWOWN(&OWNER) + CUROWNAUT(*REVOKE) /* REASSIGN OWNERSHIP TO ORIGINAL OWNER */ /* Revoke all public authorities */ RVKOBJAUT OBJ(&DTAQLIB/&DTAQ) OBJTYPE(*DTAQ) USER(*PUBLIC) + AUT(*ALL) /* To grant the original authorities to the re-created data + queue, the program reads the DSPOBJAUT outfile (created + earlier) and builds a GRTOBJAUT command string, adding + parameters and parameter values as necessary */ AUT: + RCVF MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END_AUT)) CHGVAR VAR(&CMD) VALUE('GRTOBJAUT OBJ(' *CAT &DTAQLIB *TCAT '/' + *CAT &DTAQ *TCAT ') OBJTYPE(*DTAQ) USER(' *CAT &OAUSR *TCAT + ') AUT(') IF COND(&OAOPR *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*OBJOPR')) IF COND(&OAOMGT *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*OBJMGT')) IF COND(&OAEXS *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*OBJEXIST')) IF COND(&OAREAD *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*READ')) IF COND(&OAADD *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*ADD')) IF COND(&OAUPD *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*UPD')) IF COND(&OADLT *EQ 'X') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*DLT')) /* If no specific authorities existed for the user being + processed, grant *EXCLUDE authority (no access) */ IF COND(&OAOPR *EQ ' ' *AND &OAOMGT *EQ ' ' *AND &OAEXS *EQ ' ' + *AND &OAREAD *EQ ' ' *AND &OAADD *EQ ' ' *AND &OAUPD *EQ ' ' + *AND &OADLT *EQ ' ') THEN(CHGVAR VAR(&CMD) VALUE(&CMD *BCAT + '*EXCLUDE')) CHGVAR VAR(&CMD) VALUE(&CMD *TCAT ')') CALL PGM(QCMDEXC) PARM(&CMD 256) /* EXECUTE GRTOBJAUT COMMAND */ MONMSG MSGID(CPF0000) /* If the data queue was secured by an authorization list, + execute another GRTOBJAUT command, referencing the + authorization list name in the AUTL parameter */ IF COND(&OAANAM *NE '*NONE') THEN(DO) CHGVAR VAR(&CMD) VALUE('GRTOBJAUT OBJ(' *CAT &DTAQLIB *TCAT + '/' *CAT &DTAQ *TCAT ') OBJTYPE(*DTAQ) AUTL(' *CAT &OAANAM + *TCAT ')') CALL PGM(QCMDEXC) PARM(&CMD 256) MONMSG MSGID(CPF0000) ENDDO GOTO CMDLBL(AUT) /* PROCESS ANOTHER OUTFILE RECORD */ /* Normal end of program */ END_AUT: + SNDPGMMSG MSG('Data queue' *BCAT &DTAQ *BCAT 'in' *BCAT &DTAQLIB + *BCAT 're-created.') MSGTYPE(*COMP) DLTOVR FILE(QAOBJAUT) RETURN /* Forward exception message to caller */ ERROR: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM
Reorganize Your Data Queues
Figure 1C RPG program DTAQ005RG
* These tables translate single-letter codes (like 'F' for FIFO) * into special values as required by CL commands (like *FIFO). E TABSQ1 3 3 1 TABSQ2 6 E TABYN1 2 2 1 TABYN2 4 * * Data structure RCVDS contains the data queue attributes as * retrieved by API QMHQRDQD. IRCVDS DS I B 1 40BYTRTN I B 5 80BYTAVL I B 9 120MAXL I B 13 160KEYL I 17 17 SEQ1 I 18 18 SND1 I 19 19 FORCE1 I 20 69 TEXT50 * * Binary parameter required by QMHQRDQD. I DS I B 1 40RCVLEN * C *ENTRY PLIST C PARM QDTAQ 20 C PARM MAXLEN 50 C PARM SEQ 6 C PARM KEYLEN 30 C PARM TEXT 50 C PARM FORCE 4 C PARM SENDER 4 * * Call API to retrieve data queue attributes into RCVDS. C CALL 'QMHQRDQD' C PARM RCVDS C PARM RCVLEN C PARM 'RDQD0100'FORMAT 8 C PARM QDTAQ * * Translate retrieved data into values that will be usable * by the CRTDTAQ command. For example, translate Y into *YES. C SEQ1 LOKUPTABSQ1 TABSQ2 50 C *IN50 IFEQ *ON C MOVE TABSQ2 SEQ C ENDIF C Z-ADDMAXL MAXLEN C Z-ADDKEYL KEYLEN C SND1 LOKUPTABYN1 TABYN2 50 C *IN50 IFEQ *ON C MOVE TABYN2 SENDER C ENDIF C FORCE1 LOKUPTABYN1 TABYN2 50 C *IN50 IFEQ *ON C MOVE TABYN2 FORCE C ENDIF C MOVE TEXT50 TEXT * C MOVE *ON *INLR * ** F*FIFO L*LIFO K*KEYED ** Y*YESN*NO
LATEST COMMENTS
MC Press Online