User Tools

Site Tools


rpg:data_queues

Data Queues

Simple example program showing filling and reading from a data queue.

Prototypes

      *-------------------------------------------------------------------------
      * Dataqueue Prototypes
      *-------------------------------------------------------------------------
     D sendDataToQueue...
     D                 PR                  extpgm('QSNDDTAQ')
     D   qname                       10A   const
     D   qlib                        10A   const
     D   dataLength                   5P 0 const
     D   data                     65535A   const options(*varsize)
     D   keyLength                    3P 0 const options(*nopass)
     D   keyData                  65535A   const options(*nopass)
     D   asyncRequest                10A   const options(*nopass)
     D   dataFromJrn                 10A   const options(*nopass)
      *
     D receiveDataFromQueue...
     D                 PR                  extpgm('QRCVDTAQ')
     D   qname                       10A   const
     D   qlib                        10A   const
     D   dataLength                   5P 0
     D   data                     65535A   options(*varsize)
     D   waitTime                     5P 0 const
      *
     D retrieveDataFromQueue...
     D                 PR                  extpgm('QMHRDQM')
     D   receiver                 65535A   options(*varsize)
     D   receiverLen                 10I 0 const
     D   formatName                   8A   const
     D   qqname                      20A   const
     D   msgSelection             65535A   const options(*varsize)
     D   error                      265A
      *
     D retrieveDataQueueDesc...
     D                 PR                  extpgm('QMHQRDQD')
     D   receiver                 65535A   options(*varsize)
     D   receiverLen                 10I 0 const
     D   format                       8A   const
     D   qqname                      20A   const

Program Example

      *---------------------------------------------------------------
      * Variablen
      *---------------------------------------------------------------
     D data            S           1024A
     D dataLength      S              5P 0
     D qname           S             10A   inz('MYDATAQ')
     D qlib            S             10A   inz('SCHMIDTM')
     D qdesc           DS                  qualified
     D   bytesReturned...
     D                               10I 0
     D   bytesAvailable...
     D                               10I 0
     D   messageLength...
     D                               10I 0
     D   keyLength                   10I 0
     D   sequence                     1A
     D   includeSenderId...
     D                                1A
     D   forceIndicator...
     D                                1A
     D   description                 50A
     D   typeOfDataQ                  1A
     D   automaticReclaim...
     D                                1A
     D   reserverd1                   1A
     D   numberMessages...
     D                               10I 0
     D   numberEntriesCurrentlyAllocated...
     D                               10I 0
     D   qname                       10A
     D   qlib                        10A
     D   maxEntriesAllowed...
     D                               10I 0
     D   initEntries                 10I 0
     D   maxEntriesSpecified...
     D                               10I 0
      /free
       data = 'Testdata for Queue';
       sendDataToQueue(qname : qlib : %size(data) : data);
 
       retrieveDataQueueDesc(qdesc : %size(qdesc) : 'RDQD0100':
                             qname + qlib);
       dsply %trimr('Number entries: ' + %char(qdesc.numberMessages));
 
       data = *blank;
       receiveDataFromQueue(qname : qlib : dataLength : data : 0);
       dsply %subst(data : 1 : 50);
 
       *inlr = *on;
       return;
      /end-free
rpg/data_queues.txt · Last modified: 2013/06/20 07:00 (external edit)