29
Fri, Nov
0 New Articles

Reorganize Your Data Queues

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

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

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • 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.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • 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

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • 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: