Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
RPG Report 2012
has no ratings.
Published: 03 Sep 2012
Revised: 30 Sep 2014 - 3488 days ago
Last viewed on: 18 Apr 2024 (6743 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

RPG Report 04 Sept 2012 Published by: Bob Cozzi on 03 Sep 2012 view comments

© Robert Cozzi, Jr. All rights reserved. Reproduction/Redistribution prohibited.
A midrangeNews.com Publication

Display Data Queue Description (DSPDTAQD)

Another "Missing Command" for IBM i

As an MI programmer back on the System/38 I never really got into data queues. I know that Author of Data Queues, I know they are either the internal QUEUE or Index objects depending on whether or not they are keyed, and I know you can communicate with Client Access applications using them. I also recently learned that you can do things with then related to SPOOL file management.

Since the days of needing to write in MI are over (nothing needs to be that fast, and most RPG or C code is more than good enough) I started using data queues for a variety of applications. For the most part, I find them interesting, perhaps easier to setup that a database file, and of course the IBM interfaces that require them, such as SPOOL management, give you little choice but to use a Data Queue. So now I too am a data queue users.

 
Sponsored by: BCD Software
Ad

Imagine my confusion that an object on this system, on that is widely used by applications for decades, has no corresponding DSPxxxx command. There is no DSPDTAQ (display data queue) or DSPDTAQD (display data queue description) commands. I know most people use the DMPOBJ or DMPSYSOBJ commands to view the raw entries in a data queue, and for the rare situations where you need to look at the entries, this is a good solution. Viewing the data queue description is important, and a DSPDTAQD command would be an important tool, but alas, there is none. So I wrote a simple version for all of use.

The DSPDTAQD (Display Data Queue Description) command is pretty straightforward, and there isn't a huge need to explain it. Simply compile the 3 source members and run the command as follows:

  DSPDTAQD  mylib/mydtaq

The screen shot of a sample run of the command is included at the bottom of this article.

Here is the source code for the 3 source member I created to form the DSPDTAQD command.

DSPDTAQD (Display Data Queue Description) Command Source

 DSPDTAQD:   CMD        PROMPT('Display Data Queue Description')
             /* Command processing program is: DSPDTAQD          */
     /*************************************************************/
     /*  See also...                                              */
     /*   QDDSSRC:    DSPDTAQDF                                   */
     /*   QRPGLESRC:  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') 

Display File DDS Source for the DSPDTAQD Command

      *************************************************************
      **  DSPDTAQDF  - DISPLAY FILE FOR DSPDTAQD COMMAND         **
      *************************************************************
     /*  See also...                                              */
     /*   QRPGLESRC:  DSPDTAQD                                    */
     /*   QCMDSRC:    DSPDTAQD                                    */
      *************************************************************
     A                                      CA03
     A          R FORMAT1
     A            PGMNAME       10A  O  1  2
     A                                  1 27'Display Data Queue Description'
     A                                       DSPATR(HI)
     A                                  1 70SYSNAME
     A                                  2 70DATE EDTCDE(Y)
     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) 

RPG IV Source Code for the DSPDTAQD Command

     H  BNDDIR('QC2LE')  OPTION(*NODEBUGIO : *SRCSTMT) DFTACTGRP(*NO)

     /*  See also...                                 */
     /*   QDDSSRC(DSPDTAQDF)                         */
     /*   QCMDSRC(DSPDTAQD)                          */

     FDSPDTAQDF CF   E             WORKSTN INFDS(WSDS)

     D DspDtaQD        PR
     D  DtaQ                         20A

     D DspDtaQD        PI
     D  DtaQ                         20A

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

     D wsds            DS
     D  FKey                          1A   Overlay(WSDS:369)

     D PSDS           SDS
     D  pgmName          *PROC
     D  CPFMSGID                      7A   Overlay(PSDS:40)
     D  CPFMSGD                      80A   Overlay(PSDS:91)
     D  MSGTEXT                      52A   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  Mode_Name                     8A
     D  Rmt_Loc                       8A
     D  Lcl_Loc                       8A
     D  RmtNet_ID                     8A
     D  RmtDQName                    10A
     D  RmtDQLib                     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
      /FREE
           callp(E) rtvDtaQD(DQDataF1 : %size(DQDataF1) :
               'RDQD0100' : DtaQ );

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

           if DtaQ_Type = '1' and NOT %ERROR;
              callp(E) rtvDtaQD(DQDataF2 : %size(DQDataF2) :
                  'RDQD0200' : DtaQ );
              if NOT %ERROR;
                 RmtLocName = Rmt_Loc;
                 LclLocName = Lcl_Loc;
                 ModeName = Mode_Name;
                 RmtNetID = RmtNet_ID;
                 RmtLocName = Rmt_Loc;
              endif;
           endif;

           If Auto_Rcl = '1';
              AutoRcl = '*YES';
           else;
              AutoRcl = '*NO';
           endif;

           If Force_Write = 'Y';
              ForceWrite = '*YES';
           else;
              ForceWrite = '*NO';
           endif;

           If Sender_ID= 'Y';
              SenderID= '*YES';
           else;
              SenderID= '*NO';
           endif;

           if Q_Seq = 'F';
              DtaQSeq= '*FIFO';
           elseif Q_Seq = 'K';
              DtaQSeq= '*KEYED';
           elseif Q_Seq = 'L';
              DtaQSeq= '*LIFO';
           endif;

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

           Dou FKey = F3 or FKey = ENTER;
              Exfmt Format1;
           enddo;
      /END-FREE 

Here's a look at the Data Queue Description for the default data queue created by the COZTOOLS STRPRTMON command.

Thanks for reading my column, visit the cozTools.com for more information

Cozzi Tools 2012 - Now Available

Cozzi Tools v1.0 is now available at www.cozTools.com Download the free runtime version for no-charge access to the included commands, or step up to the Developer Edition to integrate them with your own RPG applications. Visit the COZTOOLS website for the latest information; and remember to tell your friends about this free tools library.  

Call Me

Bob Cozzi is a technical advisor to IBM i clients around the world. His specialty is solving difficult problems for his clients, training their programming staffs, and performing system migration/upgrades for small shops. His consulting rates are available online. To contact Bob, send an email to: bob at rpgworld.com

You can subscribe to RPG Report (we call it "follow") by visiting the RPG Report page on midrangeNews.com and then click the FOLLOW link in the table of contents for that page. To unsubscribe, simply click that same link. You must be signed up and signed in to midrangeNews.com to start following RPG Report.

Follow Bob Cozzi on Twitter

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS