Ü  Data Queue

·         It is used for making asynchronous communication between the two jobs. If we are sending data from one job to another using data queue using QSNDDTAQ API, but at that time the receiver job is not active, then the data will be there in the queue and whenever the receiver job becomes active, it retrieves the data using the QRCVDTAQ API.

·         It facilitates fastest communication compared to when we use other things to communicate like dataarea, message queue or database files.

·         It can yet be used for synchronous communication also or within the same job.

·         We use APIs to make communication e.g. QSNDDTAQ, QRCVDTAQ.

·         The content of the data queue is messages in free format.

·         The messages on the data queue is stored in *FIFO, *LIFO or *KEYED. *KEYED means the messages can be retrieved using key value associated with the messages. In case of *KEYED we need to mention key length also.

·         First create the data queue by using CRTDAQ command

·         Data query is nothing but a queue in which are program can send a data and other program or the same program can receive the program. QSNDDTAQ is stored in QSYS.

·         We can create data queue on local system or on remote system by making the data queue type as *DDM. By default it will be *STD. In case of DDM data queue, we need to mention Remote data queue name(RMTDTAQ) and remote system name(RMTLOCNAME) also as parameter.

·         QSNDDTAQ

By using this command sent data same / another program.

QSNDDTAQ   PARM (QUEUE-NAME LIB  &LEN  &DAT)

·         QRCVDTAQ

By using this command receive data same /another program

QRCVDTAQ   PARM (QUEUE-NAME LIB &LEN &DAT &WAIT)

 

 



Example

 

Step (1): First of all create a data queue as below:

 

CRTDTAQ DTAQ(DTAQ000) TYPE(*STD) MAXLEN(300) TEXT('DATA QUEUE DTAQ000')

 

 

Step (2): Now we write one RPG program to write data to this data queue.

 

Columns . . . :    1 100                    Browse                       IROBO1/QRPGLESRC
 SEU==>                                                                        DTAQ00_RPG
 FMT D  .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++Comments+++++++++++
        *************** Beginning of data ***********************************************
0001.00      DQueue            S             10A   INZ('DTAQ000')
0002.00      DLib              S             10A   INZ('IROBO1')
0003.00      DLen              S              5  0 INZ(100)
0004.00      DData             DS
0005.00      DSYSNAME                         8    INZ('SYS00001')
0006.00      DFILLER1                         2    INZ('  ')
0007.00      DDOMAIN                          5    INZ('AS400')
0008.00      DFILLER2                         2    INZ('  ')
0009.00      DADDRESS                        30    INZ('SYS00001.AS400.NET')
0010.00      DCMDDSC           S            256A
0011.00      DCMDLEN           S             15P 5
0012.00
0013.00       *-------------------------------------------------------------
0014.00       * Main section of the program
0015.00       *-------------------------------------------------------------
0016.00      C                   EXSR      CLRDTAQ
0017.00      C                   EXSR      SNDDATA
0018.00      C                   SETON                                        LR
0019.00       *
0020.00       *
0021.00       *-------------------------------------------------------------
0022.00       *  Call the API to Send the DATA to the DATAQ
0023.00       *-------------------------------------------------------------
0024.00      C     SNDDATA       Begsr
0025.00       *
0026.00       *
0027.00      C                   call      'QSNDDTAQ'
0028.00      C                   Parm                    Queue
0029.00      C                   Parm                    Lib
0030.00      C                   Parm                    Len
0031.00      C                   Parm                    Data
0032.00       *
0033.00      C                   EndSr
0034.00
0035.00       *---------------------------------------------------------------------
0036.00       *  Clear DATAQ
0037.00       *---------------------------------------------------------------------
0038.00      C     CLRDTAQ       BegSr
0039.00       *
0040.00      C                   Eval      CMDDSC='DLTDTAQ DTAQ(IROBO1/DTAQ000)'
0041.00
0042.00      C                   Eval      CMDLEN=%len(%trim(CMDDSC))
0043.00      C                   CALL      'QCMDEXC'
0044.00      C                   PARM                    CMDDSC
0045.00      C                   PARM                    CMDLEN
0046.00       *
0047.00      C                   Eval      CMDDSC='CRTDTAQ DTAQ(IROBO1/DTAQ000) +
0048.00      C                                       MAXLEN(300)'
0049.00      C
0050.00      C                   Eval      CMDLEN=%len(%trim(CMDDSC))
0051.00      C                   CALL      'QCMDEXC'
0052.00      C                   PARM                    CMDDSC
0053.00      C                   PARM                    CMDLEN
0054.00       *
0055.00      C                   EndSr
        ****************** End of data ***********************************************


 

 

Step (3): Now we write one RPG program to retrieve data from the data queue.

 

Columns . . . :    1 100                       Browse                      IROBO1/QRPGLESRC
 SEU==>                                                                          DTAQ01_RPG
 FMT D  .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++Comments++++++++++++
        *************** Beginning of data ************************************************
0001.00      DQueue            S             10A   INZ('DTAQ000')
0002.00      DLib              S             10A   INZ('IROBO1')
0003.00      DLen              S              5  0 INZ(100)
0004.00      DData             DS
0005.00      DSYSNAME                         8
0006.00      DDOMAIN                          5
0007.00      DADDRESS                        30
0008.00      DWait             S              5  0 INZ(0)
0009.00
0010.00       *-------------------------------------------------------------
0011.00       * Main section of the program
0012.00       *-------------------------------------------------------------
0013.00      C                   EXSR      RCVDATA
0014.00      C     DATA          DSPLY
0015.00      C                   SETON                                        LR
0016.00       *
0017.00       *
0018.00       *---------------------------------------------------------------------
0019.00       *  Call the API to recive the DATA form the DATAQ
0020.00       *---------------------------------------------------------------------
0021.00      C     RCVDATA       Begsr
0022.00       *
0023.00      C                   Call      'QRCVDTAQ'
0024.00      C                   Parm                    Queue
0025.00      C                   Parm                    Lib
0026.00      C                   Parm                    Len
0027.00      C                   Parm                    Data
0028.00      C                   Parm                    Wait
0029.00       *
0030.00      C                   EndSr
0031.00
        ****************** End of data ****************************************************


 

 

OUTPUT

DSPLY  SYS00001  AS400  SYS00001.AS400.NET   

 











User Comments:



Copyright © www.go4as400.com, 2013-2023. Copyright notice   Terms of services   Privacy policy