16
Tue, Jul
4 New Articles

Display Data Queue Description

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

It's been nearly 20 years since Wayne O. Evans, a security expert and consultant who was working at IBM Rochester, came up with the idea of data queues. With the exception of messages and probably OPNQRYF, data queues are probably the most-used programmer resource on OS/400.

Data queues provide a "queue" onto which the programmer may stack data and then retrieve that data later. Since data queues are persistent objects, they may have data added to them in one job and that data may be retrieved in a secondary job. Often, in fact, multiple jobs will add data to a specific data queue, and a single batch job will retrieve the data off that data queue asynchronously. That batch job can wait for a specified period or forever for an entry to be added to the data queue.

The following commands are among the few CL commands that IBM ships with OS/400 for data queues:

  • CRTDTAQ--Create Data Queue
  • DLTDTAQ--Delete Data Queue
  • WRKDTAQ--Work with Data Queues

Displaying the Description of a *DTAQ

To take advantage of data queues, you have to use APIs. Ironically, while most RPG programmers wrongly treat APIs like a Latin course in college, you really can't use data queues without APIs. Consequently, most people are using APIs, at least when it comes to data queues.

IBM provides APIs to send and received data to and from a data queue, as well as to retrieve information about the data queue. The APIs that IBM provides to manipulate data queues are as follows:

  • QSNDDTAQ--Send Data Queue Data
  • QRCVDTAQ--Receive Data Queue Data
  • QCLRDTAQ--Clear Data Queue
  • QMHRDQM--Retrieve Data Queue Entry
  • QMHQRDQD--Retrieve Data Queue Description

The Send and Receive APIs are, of course, widely used throughout the RPG application world, so I won't bother explaining them.

The QCLRDTAQ API clears either all the entries on the specified data queue or a subset of entries identified by a "key" parameter. You specify a key to delete, and the API deletes the entries in the data queue that match that key. Normally, entries in a data queue are removed when they are retrieved with the QRCVDTAQ API, so the use of QCLRDTAQ is not widespread.

The QMHRDQM API retrieves one or more entries from a data queue. This is similar to what is done with the conventional QRCVDTAQ API, but that is where the similarity ends. The QMHRDQM API does not delete the data entries it retrieves.

The QMHRDQM and QCLRDTAQ APIs along with QRCVDTAQ and QSNDDTAQ APIs are interfaces that are used to manipulate the data on the data queue itself, whereas the QMHQRDQD API returns information about the data queue itself.

The QMHQRDQD API returns the description of the data queue along with information about the size and number of entries on the data queue. While this API is useful for testing for entries on a data queue before attempting to retrieve an entry, that capability is already integrated into the QRCVDTAQ API.

So what use is the QMHQRDQD API? It can be used to create a Display Data Queue Description (DSPDTAQD) command.

The DSPDTAQD command accepts a data queue name and displays the appropriate information about that data queue. Figure 1 contains the command definition source code for the DSPDTAQD command.

DSPDTAQD:    CMD        PROMPT('Display Data Queue Description')
             /* Command processing program is: DSPDTAQD  */
             PARM       KWD(DTAQ) TYPE(QUAL) MIN(1) +
                          PROMPT('Data queue')
 QUAL:       QUAL       TYPE(*NAME) MIN(1) EXPR(*YES)
             QUAL       TYPE(*NAME) DFT(*LIBL) SPCVAL((*LIBL) +
                          (*CURLIB)) EXPR(*YES) PROMPT('Library')

Figure 1: DSPDTAQD (Display Data Queue Description) Command Source

To compile this command, use the CRTCMD command as follows:

CRTCMD  CMD(DSPDTAQD) 

The command requires a command processing program (see Figure 3), which also requires a display file to display the data queue's information. The DDS source for this display file is listed in Figure 2.

     A                                      CA03
      * SRCMBR: DSPDTAQDF
.....A*.........R.Format++++................Keywords++++++++++++++++++++++++
     A          R FORMAT1
     A                                  1  2'DSPDTAQD'
     A                                  1 27'Display Data Queue Description'
     A                                      DSPATR(HI)
     A            MYTIME        10A  O  1 60
     A            MYDATE        10A  O  1 71
     A                                  3  4'Data queue . . . .'
     A            DTAQNAME      10A  O  3 23DSPATR(HI)
     A                                  3 42'Remote name . . . .'
     A            RMTQNAME      10A  O  3 62
     A                                  4  6'Library  . . . .'
     A            DTAQLIB       10A  O  4 24DSPATR(HI)
     A                                  4 44'Library . . . . .'
     A            RMTQLIB       10A  O  4 63
     A                                  5  4'Text . . . . . . .'
     A            TEXTDESC      50A  O  5 23
     A                                  7  6'Maximum entry length  . . . . . . -
     A                                      . . . . :'
     A            MAXLEN        10A  O  7 51
     A                                  8  6'Entry sequence. . . . . . . . . . -
     A                                      . . . . :'
     A            DTAQSEQ       10A  O  8 51
     A                                  9  6'Key length  . . . . . . . . . . . -
     A                                      . . . . :'
     A            KEYLEN        10A  O  9 51
     A                                 10  6'Force to aux storage  . . . . . . -
     A                                      . . . . :'
     A            FORCEWRITE    10A  O 10 51
     A                                 11  6'Include Sender ID . . . . . . . . -
     A                                      . . . . :'
     A            SENDERID      10A  O 11 51
     A                                 12  6'Size: Max entries . . . . . . . . -
     A                                      . . . . :'
     A            MAXENTRY      10A  O 12 51
     A                                 13 12'Initial entries . . . . . . . . . -
     A                                      . :'
     A            INITENTRY     10A  O 13 51
     A                                 14  6'Automatic reclaim . . . . . . . . -
     A                                      . . . . :'
     A            AUTORCL       10A  O 14 51
     A                                 15  6'Current number of msgs  . . . . . -
     A                                      . . . . :'
     A            CURMSGS       10A  O 15 51
     A                                 16  6'Current allocation size . . . . . -
     A                                      . . . . :'
     A            CURCAP        10A  O 16 51
     A                                 18  6'APPC device description . . . . . -
     A                                      . . . . :'
     A            APPCDEVD      10A  O 18 51
     A                                 19  6'Local location name . . . . . . . -
     A                                      . . . . :'
     A            LCLLOCNAME    10A  O 19 51
     A                                 20  6'Remote location name  . . . . . . -
     A                                      . . . . :'
     A            RMTLOCNAME    10A  O 20 51
     A                                 21  6'Mode name . . . . . . . . . . . . -
     A                                      . . . . :'
     A            MODENAME      10A  O 21 51
     A                                 22  6'Remote network ID . . . . . . . . -
     A                                      . . . . :'
     A            RMTNETID      10A  O 22 51
     A                                 24  6'F3=Exit'
     A                                      COLOR(BLU)

Figure 2: DSPDTAQDF Source

The final piece of this puzzle is the command processing program for the DSPDTAQD command. The RPG IV program DSPDTAQD receives the name of the data queue and uses the QMHQRDQD API to retrieve the description of that data queue. The source for the DSPDDTAQD RPG IV program is listed in Figure 3.

     H  DFTACTGRP(*NOBNDDIR('QC2LE'
     H  OPTION(*NODEBUGIO : *SRCSTMT
      **  DSPDTAQD – Download at: http://www.rpgiv.com/newsletter
      /IF DEFINED(TOOLKIT)
     BNDDIR('TOOLKIT/TOOLKIT')
      /ENDIF
     FDSPDTAQDF CF   E             WORKSTN INFDS(WSDS)

     D DspDtaQD        PR
     D  DtaQ                         20A

     D DspDtaQD        PI
     D  DtaQ                         20A

     D GetDtaQD        PR                  Extpgm('QMHQRDQD')
     D  RtnVariable                2000A   OPTIONS(*VARSIZE)
     D  RtnVarLen                    10I 0 Const
     D  APIFMT                        8A   Const
     D  DTAQ                         20A   Const

      /IF DEFINED(TOOLKIT)
     D/COPY TOOLKIT/TOOLKIT
      /ENDIF

     D wsds            DS
     D  FKey                          1A   Overlay(WSDS:369)
     D PSDS           SDS
     D  CPFMSGID                      7A   Overlay(PSDS:40)
     D  CPFMSGD                      80A   Overlay(PSDS:91)
     D  MSGTEXT                      50A   Overlay(PSDS:91)

     D F3              C                   Const(X'33')
     D ENTER           C                   Const(X'F1')

     D DQDataF1        DS                  Inz
     D  BytesRtn                     10I 0
     D  BytesAvail                   10I 0 Inz(%size(DQDataF1))
     D  Max_Len                      10I 0
     D  Key_Len                      10I 0
     D  Q_Seq                         1A
     D  Sender_ID                     1A
     D  Force_Write                   1A
     D  TextDesc                     50A
     D  DtaQ_Type                     1A
     D  Auto_Rcl                      1A
     D  Reserved1                     1A
     D  Cur_Msgs                     10I 0
     D  CurEntry_Cap                 10I 0
     D  DtaQName                     10A
     D  DtaQLib                      10A
     D  Max_Entry                    10I 0
     D  Init_Entry                   10I 0

     D DQDataF2        DS                  Inz
     D  BytesRtn2                    10I 0
     D  BytesAvail2                  10I 0 Inz(%size(DQDataF2))
     D  APPCDevD                     10A
     D  ModeName                     10A
     D  RmtLocName                   10A
     D  LclLocName                   10A
     D  RmtNetID                     10A
     D  RmtDtaQName                  10A
     D  RmtDtaQLib                   10A
     D  DtaQName2                    10A
     D  DtaQLib2                     10A
     D QSYSDATE        S               D   Datfmt(*USA) Inz(*SYS)
     D QSYSTIME        S               T   Timfmt(*USA) Inz(*SYS)

     C                   MOVE      *ON           *INLR

     C                   callp(E)  GetDtaQD(DQDataF1 : %size(DQDataF1) :
     C                                       'RDQD0100' : DtaQ )

     C                   if        %ERROR and CPFMSGID = 'CPF9801'
     C     MSGTEXT       DSPLY
     C                   return
     C                   endif

     C                   if        DtaQ_Type = '1' and NOT %ERROR
     C                   callp(E)  GetDtaQD(DQDataF2 : %size(DQDataF2) :
     C                                       'RDQD0200' : DtaQ )
     C                   endif

     C                   If        Auto_Rcl = '1'
     C                   eval      AutoRcl = '*YES'
     C                   else
     C                   eval      AutoRcl = '*NO'
     C                   endif

     C                   If        Force_Write = 'Y'
     C                   eval      ForceWrite = '*YES'
     C                   else
     C                   eval      ForceWrite = '*NO'
     C                   endif

     C                   If        Sender_ID= 'Y'
     C                   eval      SenderID= '*YES'
     C                   else
     C                   eval      SenderID= '*NO'
     C                   endif

     C                   Select
     C                   When      Q_Seq = 'F'
     C                   eval      DtaQSeq= '*FIFO'
     C                   When      Q_Seq = 'K'
     C                   eval      DtaQSeq= '*KEYED'
     C                   When      Q_Seq = 'L'
     C                   eval      DtaQSeq= '*LIFO'
     C                   endSL

      **  Convert the numeric entries to left-justified char values
     C                   eval      MaxLen = %Char(Max_Len)
     C                   if        Q_Seq = 'K'
     C                   eval      KeyLen = %Char(Key_Len)
     C                   else
     C                   eval      KeyLen = 'N/A'
     C                   endif
     C                   eval      CurMsgs= %Char(Cur_Msgs)
     C                   eval      CurCap = %Char(CurEntry_Cap)
     C                   eval      MaxEntry = %Char(Max_Entry)
     C                   eval      InitEntry = %Char(Init_Entry)

     C                   eval      myDate = %Char(QSysDate)
     C                   eval      myTime = %Char(QSysTime)

     C                   Dou       FKey = F3 or FKey = ENTER
     C                   Exfmt     Format1
     C                   enddo

Figure 3: RPG IV Source for DSPDTAQD Program

Once this command is compiled, you can use it to display the description of any data queue for which you have authority.

Figure 4 illustrates an example of the information that is displayed by the DSPDTAQD command.

http://www.mcpressonline.com/articles/images/2002/Display%20Data%20Queue%20Description00.png

Figure 4: The Display from the DSPDTAQD Command (Click image to enlarge.)

Bob Cozzi has been programming in RPG since 1978. Since then, he has written many articles and several books, including The Modern RPG Language--the most widely used RPG reference manual in the world. Bob is also a very popular speaker at industry events such as RPG World and is the author of his own Web site and of the RPG ToolKit, an add-on library for RPG IV programmers.

BOB COZZI

Bob Cozzi is a programmer/consultant, writer/author, and software developer. His popular RPG xTools add-on subprocedure library for RPG IV is fast becoming a standard with RPG developers. His book The Modern RPG Language has been the most widely used RPG programming book for more than a decade. He, along with others, speaks at and produces the highly popular RPG World conference for RPG programmers.


MC Press books written by Robert Cozzi available now on the MC Press Bookstore.

RPG TnT RPG TnT
Get this jam-packed resource of quick, easy-to-implement RPG tips!
List Price $65.00

Now On Sale

The Modern RPG IV Language The Modern RPG IV Language
Cozzi on everything RPG! What more could you want?
List Price $99.95

Now On Sale

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: