ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Creating a simular data queue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a simular data queue

    I am trying to create a data queue that is the same as my production library.

    I'm having trouble creating a duplicate obj for this data queue.

    Any suggestions on creating the same data queue in another library?

    Thanks,

    DAC

    Object Type Library Attribute Text
    CMPSUMQ *DTAQ TMSEMCFIL Component Summary Data Queu

  • #2
    Re: Creating a simular data queue

    CrtDupObj? or just CrtDtaQ (prompt it)
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Creating a simular data queue

      A couple days have gone by without a working answer. Unfortunately, CRTDUPOBJ doesn't allow OBJTYPE(*DTAQ). Duplicating data queues isn't quite straight forward, but it's not too hard. Here are a couple basic programs that can help.

      First is CL program CRTDUPDTAQ:
      Code:
      /* +
         CRTDUPDTAQ -- CPP for CRTDUPDTAQ command                           +
             Receives a qualified *DTAQ name and a target library name.     +
             Retrieves *DTAQ attributes and creates a duplicate *DTAQ in    +
             the target library.                                            +
             Requires the RTNDTAQD command to retrieve current attributes.  +
             Uses temporary message descriptions to format the CRTDTAQ      +
             command. This handles the SIZE() parameter where a numeric     +
             value is required, but usually a character 'special value'     +
             is provided.                                                   +
      */
      
      pgm      ( +
                 &pqDtaQ      +
                 &pNewLib     +
               )
      
         dcl     &pqDtaQ      *char    20
         dcl     &pNewLib     *char    10
      
      
         dcl     &DtaQ        *char    10
         dcl     &DtaQLib     *char    10
      
         dcl     &MaxELen     *int
         dcl     &FrcI        *char     4
         dcl     &Seq         *char     6
         dcl     &KeyLen      *int
         dcl     &SndrId      *char     4
         dcl     &Text        *char    50
         dcl     &AutRcl      *char     4
         dcl     &MaxMsg      *char    10
         dcl     &InitMsg     *int
      
         dcl     &msgdta      *char   132
         dcl     &msgtxt      *char   256
         dcl     &cdCmd       *char   128     value( +
                                                    'CRTDTAQ DTAQ(&2/&1) +
                                                             TYPE(&3) +
                                                             MAXLEN(&4) +
                                                             FORCE(&5) +
                                                             SEQ(&6) +
                                                             SENDERID(&7) +
                                                             SIZE(&8 &9) +
                                                             AUTORCL(&10) +
                                                             TEXT(''&11'')' +
                                                   )
         dcl     &cdCmdK      *char   128     value( +
                                                    'CRTDTAQ DTAQ(&2/&1) +
                                                             TYPE(&3) +
                                                             MAXLEN(&4) +
                                                             FORCE(&5) +
                                                             SEQ(&6) +
                                                             KEYLEN(&7) +
                                                             SENDERID(&8) +
                                                             SIZE(&9 &10) +
                                                             AUTORCL(&11) +
                                                             TEXT(''&12'')' +
                                                   )
      
      
         chgvar            &DtaQ           %sst( &pqDtaQ    1  10 )
         chgvar            &DtaQLib        %sst( &pqDtaQ   11  10 )
      
      
         if ( &DtaQLib  *eq &pNewLib )  do
            sndpgmmsg  msgid( CPF9898 ) msgf( QCPFMSG )          +
                         msgdta( 'The new library must be +
                         different from the original library' )  +
                         msgtype( *ESCAPE )
            return
         enddo
      
      
         rtndtaqd   dtaq( &DtaQLib/&DtaQ )           +
                      maxlen( &MaxELen )             +
                      force( &FrcI )                 +
                      seq( &Seq )                    +
                      keylen( &KeyLen )              +
                      senderid( &SndrId )            +
                      text( &Text )                  +
                      autrcl( &AutRcl )              +
                      maxmsg( &MaxMsg )              +
                      initmsg( &InitMsg )
      
         crtmsgf     QTEMP/crtdupdtaq
         monmsg    ( CPF2112 )                       /* MsgF exists... */
         rcvmsg      msgtype( *LAST ) rmv( *YES )
      
      /* Handle *FIFO/*LIFO *DTAQs... */
         if ( &KeyLen *eq 0 )  do
      
            addmsgd  FMT0001  msgf( QTEMP/crtdupdtaq )  +
                       msg( &cdCmd  ) +
                       fmt( (*CHAR 10) (*CHAR 10) (*CHAR 4) (*BIN 4) +
                            (*CHAR 4) (*CHAR 6) +
                            (*CHAR 4) (*CHAR 10) (*BIN 4) (*CHAR 4) (*CHAR 50) )
            monmsg ( CPF2412 )                       /* MsgID exists... */
      
            chgvar         &msgdta       ( +
                                           &DtaQ        *cat  +
                                           &pNewLib     *cat  +
                                           '*STD'       *cat  +
                                           '    '       *cat  +
                                           &FrcI        *cat  +
                                           &Seq         *cat  +
                                           &SndrId      *cat  +
                                           &MaxMsg      *cat  +
                                           '    '       *cat  +
                                           &AutRcl      *cat  +
                                           &Text              +
                                         )
            chgvar   %bin( &msgdta  25 4 ) &MaxELen
            chgvar   %bin( &msgdta  53 4 ) &InitMsg
      
         enddo
      /* Handle *KEYED *DTAQs... */
         else  do
      
            addmsgd  FMT0001  msgf( QTEMP/crtdupdtaq )  +
                       msg( &cdCmdK ) +
                       fmt( (*CHAR 10) (*CHAR 10) (*CHAR 4) (*BIN 4) +
                            (*CHAR 4) (*CHAR 6) (*BIN 4) +
                            (*CHAR 4) (*CHAR 10) (*BIN 4) (*CHAR 4) (*CHAR 50) )
            monmsg ( CPF2412 )                       /* MsgID exists... */
      
            chgvar         &msgdta       ( +
                                           &DtaQ        *cat  +
                                           &pNewLib     *cat  +
                                           '*STD'       *cat  +
                                           '    '       *cat  +
                                           &FrcI        *cat  +
                                           &Seq         *cat  +
                                           '    '       *cat  +
                                           &SndrId      *cat  +
                                           &MaxMsg      *cat  +
                                           '    '       *cat  +
                                           &AutRcl      *cat  +
                                           &Text              +
                                         )
            chgvar   %bin( &msgdta  25 4 ) &MaxELen
            chgvar   %bin( &msgdta  39 4 ) &KeyLen
            chgvar   %bin( &msgdta  57 4 ) &InitMsg
      
         enddo
      
         rtvmsg      FMT0001  msgf( QTEMP/crtdupdtaq )  +
                       msgdta( &msgdta )  +
                       msg( &msgtxt )
      
         dltmsgf     QTEMP/crtdupdtaq
      
         call    QCMDEXC      ( +
                                &msgtxt      +
                                256          +
                              )
      
         return
      
      endpgm
      A CRTDUPDTAQ *CMD can be used as a wrapper:
      Code:
       CRTDUPDTAQ: CMD        PROMPT('Create duplicate *dtaq')
      
      
      /*  DTAQ: The qualified name of the *dtaq to retrieve...            */
      
                   PARM       KWD(DTAQ) TYPE(DTAQNAM) MIN(1) PROMPT('Dtaq +
                                name')
       DTAQNAM:    QUAL       TYPE(*NAME) LEN(10) MIN(1)
                   QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                                SPCVAL((*CURLIB) (*LIBL)) PROMPT('Library')
      
                   PARM       KWD(TOLIB) TYPE(*NAME) LEN(10) MIN(1) +
                                PROMPT('To library')
      Note that only *STD *DTAQs are handled in this version. If you need *DDM *DTAQs to be handled, feel free to make the changes needed. I don't personally have that variant available to post here at the moment.

      Also, note that ownership and authorities are not duplicated, nor are *DTAQ entries. Once CRTDUPDTAQ is available, it's fairly easy to include all of those.

      The program relies on a RTNDTAQD *CMD to retrieve the needed attributes from the existing *DTAQ. A sample RTNDTAQD *CMD CL CPP:
      Code:
      /* +
         RTNDTAQD -- CPP for RTNDTAQD command                               +
             Retrieves *DTAQ attributes and returns most attributes out for +
             command return PARMs.                                          +
             Attributes are formatted for use as CRTDTAQ PARMs.             +
      */
      
       pgm   ( +
               &pQDtaQ      +
               &pMaxLen     +
               &pForce      +
               &pSeq        +
               &pKeyLen     +
               &pSenderId   +
               &pText       +
               &pAutRcl     +
               &pNbrMsg     +
               &pAlcMsg     +
               &pAlwMsg     +
               &pMaxSpec    +
               &pIniMsg     +
             )
      
         dcl   &pQDtaQ      *char    20
         dcl   &pMaxLen     *int
         dcl   &pForce      *char     4
         dcl   &pSeq        *char     6
         dcl   &pKeyLen     *int
         dcl   &pSenderId   *char     4
         dcl   &pText       *char    50
         dcl   &pAutRcl     *char     4
         dcl   &pNbrMsg     *int
         dcl   &pAlcMsg     *int
         dcl   &pAlwMsg     *int
         dcl   &pMaxSpec    *char    10
         dcl   &pIniMsg     *int
      
      
         dcl   &DtaQ        *char    10
         dcl   &DtaQLib     *char    10
      
         dcl   &AutRcl      *char     1
         dcl   &Force       *char     1
         dcl   &Seq         *char     1
         dcl   &SenderId    *char     1
         dcl   &MaxSpec     *int
      
         dcl   &DtaQD       *char   120
      
         dcl   &CStkCtr     *char     4
         dcl   &CStkIDLen   *char     4
         dcl   &RSNM0100    *char    29
      
      
         monmsg ( MCH3601 ) /* Ignore unpassed parameters... */
         monmsg ( CPF0000 MCH0000 ) exec( goto  Std_Err )
      
      
         chgvar            &DtaQ            %sst( &pQDtaQ  1 10 )
         chgvar            &DtaQLib         %sst( &pQDtaQ 11 10 )
      
         call  Qsys/QMHQRDQD    ( +
                                  &DtaQD       +
                                  x'00000080'  +
                                  'RDQD0100'   +
                                  &pQDtaQ      +
                                )
      
         chgvar            &pMaxLen         %bin( &DtaQD   9  4 )
         chgvar            &pKeyLen         %bin( &DtaQD  13  4 )
      
         chgvar            &Seq             %sst( &DtaQD  17  1 )
      
         select
            when ( &Seq *eq 'F' )  +
               chgvar      &pSeq                  '*FIFO'
            when ( &Seq *eq 'K' )  +
               chgvar      &pSeq                  '*KEYED'
            when ( &Seq *eq 'L' )  +
               chgvar      &pSeq                  '*LIFO'
            otherwise  +
               chgvar      &pSeq                  '*N'
         endselect
      
         chgvar            &SenderId        %sst( &DtaQD  18  1 )
      
         select
            when ( &SenderId *eq 'Y' )  +
               chgvar      &PSenderId             '*YES'
            when ( &SenderId *eq 'N' )  +
               chgvar      &PSenderId             '*NO'
            otherwise  +
               chgvar      &PSenderId             '*N'
         endselect
      
         chgvar         &Force           %sst( &DtaQD  19  1 )
      
         select
            when ( &Force *eq 'Y' )  +
               chgvar      &pForce                '*YES'
            when ( &Force *eq 'N' )  +
               chgvar      &pForce                '*NO'
            otherwise  +
               chgvar      &pForce                '*N'
         endselect
      
         chgvar            &pText           %sst( &DtaQD  20 50 )
      
         chgvar            &AutRcl          %sst( &DtaQD  71  1 )
      
         select
            when ( &AutRcl *eq 'Y' )  +
               chgvar      &pAutRcl               '*YES'
            when ( &Force  *eq 'N' )  +
               chgvar      &pAutRcl               '*NO'
            otherwise  +
               chgvar      &pAutRcl               '*N'
         endselect
      
         chgvar            &pNbrMsg         %bin( &DtaQD  73  4 )
         chgvar            &pAlcMsg         %bin( &DtaQD  77  4 )
         chgvar            &pAlwMsg         %bin( &DtaQD 101  4 )
         chgvar            &pIniMsg         %bin( &DtaQD 105  4 )
         chgvar            &MaxSpec         %bin( &DtaQD 109  4 )
      
         select
             when ( &MaxSpec *eq -1 )  +
               chgvar      &pMaxSpec              '*MAX16MB'
             when ( &MaxSpec *eq -2 )  +
               chgvar      &pMaxSpec              '*MAX2GB'
             otherwise  +
               chgvar      &pMaxSpec              &MaxSpec
         endselect
      
      
         Qsys/rmvmsg     clear( *ALL )
      
         return
      
      Std_Err:
      
         /* Move any *DIAG messages up the stack...        */
      
         call       QSYS/QMHMOVPM       ( +
                                          '    '          +
                                          '*DIAG     '    +
                                          x'00000001'     +
                                          '*         '    +
                                          x'00000001'     +
                                          x'00000000'     +
                                        )
         monmsg   ( CPF0000 MCH0000 )
      
         /* Resend any *ESCAPE messages up the stack...     */
      
         chgvar    %bin( &CStkCtr   )        2
         monmsg  ( CPF0000 MCH0000 )
         chgvar    %bin( &CStkIDLen )        1
         monmsg  ( CPF0000 MCH0000 )
      
         chgvar          &RSNM0100         ( &CStkCtr     *CAT +
                                             '*NONE     *NONE     ' *CAT +
                                             &CStkIDLen   *CAT +
                                             '*'               +
                                           )
         monmsg  ( CPF0000 MCH0000 )
      
      
         call       QSYS/QMHRSNEM       ( +
                                          '    '          +
                                          x'00000000'     +
                                          &RSNM0100       +
                                          x'0000001D'     +
                                          'RSNM0100 '     +
                                          '*               ' +
                                          x'00000000'     +
                                        )
         monmsg   ( CPF0000 MCH0000 )
      
         return
      
      endpgm
      The RTNDTAQD *CMD:
      Code:
      /* +
         CRTCMD CMD( mylib/RTNDTAQD )                           +
                PGM( mylib/RTNDTAQD )                           +
                SRCFILE( mylib/QCMDSRC )                        +
                ALLOW( *IREXX *BREXX *BPGM *IPGM *BMOD *IMOD )  +
                HLPPNLGRP( mylib/RTNDTAQD )                     +
                HLPID( RTNDTAQD )                               +
      */
       RTNDTAQD:   CMD        PROMPT('Return *dtaq description')
      
      /*  DTAQ: The qualified name of the *dtaq to retrieve...            */
      
                   PARM       KWD(DTAQ) TYPE(DTAQNAM) MIN(1) PROMPT('Dtaq +
                                name' 1)
       DTAQNAM:    QUAL       TYPE(*NAME) LEN(10) MIN(1)
                   QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                                SPCVAL((*CURLIB) (*LIBL)) PROMPT('Library')
      
      
                   PARM       KWD(MAXLEN) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Maximum entry length')
      
                   PARM       KWD(FORCE) TYPE(*CHAR) LEN(4) RTNVAL(*YES) +
                                CHOICE('Character (4)') PROMPT('Force +
                                indicator')
                   PARM       KWD(SEQ) TYPE(*CHAR) LEN(6) RTNVAL(*YES) +
                                CHOICE('Character (6)') PROMPT('Sequence')
                   PARM       KWD(KEYLEN) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Key length')
                   PARM       KWD(SENDERID) TYPE(*CHAR) LEN(4) +
                                RTNVAL(*YES) CHOICE('Character (4)') +
                                PROMPT('Sender ID')
                   PARM       KWD(TEXT) TYPE(*CHAR) LEN(50) RTNVAL(*YES) +
                                PROMPT('Text')
                   PARM       KWD(AUTRCL) TYPE(*CHAR) LEN(4) RTNVAL(*YES) +
                                CHOICE('Character (4)') PROMPT('Automatic +
                                reclaim')
                   PARM       KWD(NBRMSG) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Number of messages queued')
                   PARM       KWD(ALCMSG) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Number of messages allocated')
                   PARM       KWD(ALWMSG) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Number of messages allowed')
                   PARM       KWD(MAXMSG) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +
                                PROMPT('Maximum queue size')
                   PARM       KWD(INITMSG) TYPE(*INT4) RTNVAL(*YES) +
                                PROMPT('Initial messages on queue')
      If desired, some UIM 'help' can be assigned to the RTNDTAQ *CMD:
      Code:
      :pnlgrp.
      
      .*--------------------------------------------------------------------
      
      :help name=rtndtaqd.
      
      Return *dtaq description (RTNDTAQD) -- HELP
      :p.
      The RTNDTAQD command returns the attributes (description) of any
      non-DDM data queue.
      :p.
      Use this command in a CL program when you need to determine the
      attributes of an existing *dtaq. This might be, for example,
      when you need to recreate a *dtaq in order to recover its unused
      space.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/dtaq'.
      
      Data queue (DTAQ) -- Help
      :xh3.Data queue (DTAQ)
      :p.Specifies the name of the data queue to return attributes from.
      :p.The possible values are:
      :parml.
      :pt.:pk.dtaq-name:epk.
      :pd.Enter the name of the data queue that you want the attributes
      returned from.
      The data queue must exist when the command is executed.
      :lp.The possible library values are:
      :pt.:pk def.*CURLIB:epk.
      :pd.The current library will be used.
      If you have not assigned a
      library as the current library, QGPL will be used.
      :pt.:pk.*LIBL:epk.
      :pd.The job's library list is to be searched for a data queue
      matching the data queue name.
      :pt.:pk.library-name:epk.
      :pd.Enter the name of the library where the data queue will be
      found.
      :nt.
      Data queues created in the QTEMP and QRPLOBJ libraries are not forced
      to permanent storage; they are deleted when those libraries are
      cleared at sign-off and system IPL, respectively.
      :ent.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/maxlen'.
      
      Maximum entry length (MAXLEN) -- Help
      :xh3.Maximum entry length (MAXLEN)
      :p.
      The maximum allowed length of messages.
      The value that was specified with the MAXLEN keyword on the
      CRTDTAQ command.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/force'.
      
      Force indicator (FORCE) -- Help
      :xh3.Force indicator (FORCE)
      :p.
      If the data queue is forced to auxiliary
      storage when entries are sent or received for the specified data
      queue.  Possible values returned are:
      :parml.
      :pt.:pk.*YES:epk.
      :pd.The data queue is forced to auxiliary storage after
      entries are sent or received.
      :pt.:pk.*NO:epk.
      :pd.The data queue is not forced to auxiliary storage after
      entries are sent or received.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/seq'.
      
      Sequence (SEQ) -- Help
      :xh3.Sequence (SEQ)
      :p.
      The sequence in which messages can be removed
      from the queue. Possible values returned are:
      :parml.
      :pt.:pk.*FIFO:epk.
      :pd.
      First-in first-out
      :pt.:pk.*KEYED:epk.
      :pd.
      Keyed
      :pt.:pk.*LIFO:epk.
      :pd.
      Last-in first-out
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/keylen'.
      
      Key length (KEYLEN) -- Help
      :xh3.Key length (KEYLEN)
      :p.
      If the specified data queue was created as a
      keyed type, this field contains the length, in bytes, of the
      message reference key.  Values range from 1 to 256.  If the
      specified queue is not a keyed queue, the value is 0.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/senderid'.
      
      Sender ID (SENDERID) -- Help
      :xh3.Sender ID (SENDERID)
      :p.
      Include sender ID.  If the queue was created to include the
      sender ID with sent messages.  Possible values returned are:
      :parml.
      :pt.:pk.*YES:epk.
      :pd.
      The sender ID is included when data is sent to the data
      queue.
      :pt.:pk.*NO:epk.
      :pd.
      The sender ID is not included when data is sent to the
      data queue.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/text'.
      
      Text (TEXT) -- Help
      :xh3.Text (TEXT)
      :p.
      The text description of the data queue.  The
      field contains blanks if no text description was specified when
      the data queue was created.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/autrcl'.
      
      Automatic reclaim (AUTRCL) -- Help
      :xh3.Automatic reclaim (AUTRCL)
      :p.
      Specifies whether the storage allocated for the data queue
      is automatically reclaimed (released) when the data queue
      is empty.
      :nt.
      This parameter is valid only when TYPE(*STD) is
      specified.
      :ent.
      :parml.
      :pt.:pk.*YES:epk.
      :pd.
      The storage allocated for the data queue is released
      when the data queue is empty.  Storage for the Initial
      Number of Entries value will remain allocated.
      :pt.:pk.*NO:epk.
      :pd.
      The storage allocated for the data queue is not
      released when the data queue is empty.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/nbrmsg'.
      
      Number of messages (NBRMSG) -- Help
      :xh3.Number of messages (NBRMSG)
      :p.
      The number of messages currently
      on the data queue.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/alcmsg'.
      
      Number of messages allocated (ALCMSG) -- Help
      :xh3.Number of messages allocated (ALCMSG)
      :p.
      The number of entries that will fit into the data queue before it is
      extended. When the queue is extended, additional storage is allocated
      for the queue. The data queue can be extended until it reaches the
      value for the maximum number of entries allowed.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/alwmsg'.
      
      Number of messages allowed (ALWMSG) -- Help
      :xh3.Number of messages allowed (ALWMSG)
      :p.
      The maximum number of messages that will fit into the data queue when
      it is full.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/maxmsg'.
      
      Maximum number of messages (MAXMSG) -- Help
      :xh3.Maximum number of messages (MAXMSG)
      :p.
      The maximum number of
      messages that can be placed on the queue without causing the
      queue to overflow.
      :parml.
      :pt.:pk.*MAX16MB:epk.
      :pd.
      The system will calculate the maximum number of
      entries that can be added to the queue and will be
      allowed to grow to a maximum size of approximately 16
      megabytes(MB).  One megabyte equals 1,048,576 bytes.
      This value with an initial number of entries of 16
      provides compatibility with releases of the operating
      system earlier than Version 4 Release 5 Modification 0
      (V4R5M0).
      :pt.:pk.*MAX2GB:epk.
      :pd.
      The system will calculate the maximum number of
      entries that can be added to the data queue.  The data
      queue will be allowed to grow to a maximum size of
      approximately 2 gigabytes (GB). One gigabyte equals
      1,073,741,824 bytes.
      :pt.:pk.number-of-entries:epk.
      :pd.
      The data queue will be allowed to hold at least this
      number of entries.  Based on the extend size used by
      the machine, the maximum number of data queue entries
      may be slightly higher than the specified value.  The
      value specified must be greater than 0.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :help name='rtndtaqd/initmsg'.
      
      Initial number messages (INITMSG) -- Help
      :xh3.Initial number messages (INITMSG)
      :p.
      Specifies the amount of storage that will initially be
      allocated to the data queue.  The queue will be created to
      hold the initial number of entries of the maximum entry
      length.
      :parml.
      :pt.:pk.initial-number-of-entries:epk.
      :pd.Specify the value for the initial number of entries
      that the data queue can hold.  The value must be
      greater than 0.
      :eparml.
      
      :ehelp.
      
      .*--------------------------------------------------------------------
      
      :epnlgrp.
      The RTNDTAQD *CMD isn't required. Code from the RTNDTAQD CPP can be inserted into the CRTDUPDTAQ CL so that a single program is created. All code should compile on V5R3 and later. If necessary, V5R3-specific code can be modified for earlier releases. (E.g., SELECT/ENDSELECT can be changed to nested IF/ELSE/ENDIF.) Features from V5R4 and later were not used, though some things would make cleaner code. (E.g., a data structure for &msgdta would make the value substitutions clearer.)

      The programming builds a CRTDTAQ command as a command string for the QCMDEXC API. This reduces some code that would be needed to handle the CRTDTAQ SIZE() parameter.

      That PARM is defined as an integer, but it accepts *MAX16MB and *MAX2GB as 'special values'. There is no good way to have a CL program supply numeric integer values and character 'special values' in the same CL variable, so the CRTDTAQ command can't be a compiled statement in the program if an "exact" duplicate is needed. If a command string is built, both numeric and alphabetic characters can be placed in the same positions in a command string without having the CRTDTAQ resolve a CL variable.

      A temporary *MSGF is created and a message description is added to it. The 1st-level text is a 'template' of a CRTDTAQ command with substitution variables in place of each PARM value. The *DTAQ attributes are placed into the message descriptions MSGDTA() area. When the 1st-level message text is resolved with RTVMSG, the parameter values are cleanly inserted into the CRTDTAQ template, including whatever was resolved for the SIZE() parameter.

      Two variants of a CRTDTAQ command string are available. The first is for *FIFO and *LIFO *DTAQs, and the second is for *KEYED. The *KEYED variant inclues the KEYLEN() PARM and allows the MSGDTA() to hold a key-length value. (A single message description could be adapted to handle both variants, but it's simpler just to do them separately.

      A *DTAQ object can be dumped with DMPOBJ to look at its attributes and content. Or the QMHQRDQD API can be called in a program to resolve attributes in human-readable form. For quick uses, this is REXX procedure SHODTAQD:
      Code:
      parse arg pDTAQ pLIB
      
      pDTAQ    = TRANSLATE( STRIP( pDTAQ ))
      pLIB     = TRANSLATE( STRIP( pLIB ))
      if pLIB = '' then
         pLIB = '*LIBL'
      
      rcvvar   = copies( ' ', 112 )
      qDTAQ    = SUBSTR( pDTAQ, 1, 10 )SUBSTR( pLIB, 1, 10 )
      
      say qDTAQ
      
           "call QMHQRDQD ( ",
                            " &rcvvar          ",
                            " x'00000070'      ",
                            " 'RDQD0100'       ",
                            " &qDTAQ           ",
                         ")                   "
      
      xRCVVAR     = C2X( rcvvar )
      
      say 'Message length'     X2D( SUBSTR( xRCVVAR, 17, 8 ) )
      say 'Key length'         X2D( SUBSTR( xRCVVAR, 25, 8 ) )
      say 'Sequence'           SUBSTR(  RCVVAR, 17, 1 )
      say 'Include sender'     SUBSTR(  RCVVAR, 18, 1 )
      say 'Force'              SUBSTR(  RCVVAR, 19, 1 )
      say 'Text'               SUBSTR(  RCVVAR, 20, 50 )
      say 'Type'               SUBSTR(  RCVVAR, 70, 1 )
      say 'Auto-reclaim'       SUBSTR(  RCVVAR, 71, 1 )
      say 'Number of messages' X2D( SUBSTR( xRCVVAR, 145, 8 ) )
      say 'Number allocated'   X2D( SUBSTR( xRCVVAR, 153, 8 ) )
      say 'Number allowed'     X2D( SUBSTR( xRCVVAR, 201, 8 ) )
      say 'Number initial'     X2D( SUBSTR( xRCVVAR, 209, 8 ) )
      xmaxspec    =      SUBSTR( xRCVVAR, 217 )
      select
          when xmaxspec = 'FFFFFFFF' then
             maxspec = '*MAX16MB'
          when xmaxspec = 'FFFFFFFE' then
             maxspec = '*MAX2GB'
          otherwise
             maxspec = X2D( xmaxspec )
      end
      say 'Maximum specified'  maxspec
      
         exit
      Run it as either:
      Code:
      STRREXPRC SRCMBR( SHODTAQD )
                SRCFILE( mylib/QREXSRC ) 
                PARM( 'mydtaq mylib' )
      ...or for *LIBL, as:
      Code:
      STRREXPRC SRCMBR( SHODTAQD )      
                SRCFILE( mylib/QREXSRC ) 
                PARM( mydtaq )
      PDM option 16 can be used as long as the option is prompted for the PARM() value. Modify it to request a *DTAQ name when one isn't provided if you wish. The displayed attributes are the actual returned values except for the SIZE() values that may be converted to *MAX16MB or *MAX2GB. The procedure can be used to examine attributes and to verify duplicated attributes.

      Tom
      Tom

      There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

      Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

      Comment


      • #4
        Re: Creating a simular data queue

        how bout just a save object and restore to different library?
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Creating a simular data queue

          For most systems (and developers), save/restore works perfectly and probably should be the first thought. It's not often not my first thought, though, due to security restrictions on save/restore authorities.

          Sometimes the easy way gets obscured by secondary details.

          Tom
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment

          Working...
          X