Using the REXX Queue

This is example is an illustration of using the REXX Queue to populate a subfile. In this instance, the REXX queue has been loaded by a previous program on the invocation stack. This snippett is from a program that reads whatever was loaded into the queue and uses the data to present a subfile display.


     D GetFromQueue    PR                  EXTPGM('QREXQ')
     D FUNT                           1
     D BUF                          128
     D BUFLEN                         9B 0
     D FLAG                           4B 0
     D RCODE                          4B 0

     D WAIVED        E DS                  extname(CAWCNFWF)



           DOU EndOfFees or sfllod >= sflmax;
              rxbuff = *blank;
              rxfunc = 'P';
              rxblen = 128;
              rxflag = 0;
              rxcode = 0;
              GetFromQueue( rxfunc: rxbuff: rxblen: rxflag: rxcode);
              IF rxCODE = 0;
                 waived = rxbuff;
              ELSE;
                 EndOfFees = *ON;
              ENDIF;
              IF EndOfFees;
                 Sflend = *ON;
              ELSE ;
              sflrcn = sflrcn + 1;
              sfllod = sfllod + 1;
              RRNSI = SFLRCN;
              Z$RRN1 =SFLRCN;
              zfamt = CFAmt;
              zfCODE= CFtrn;
              zfACCT= CFact;
              WRITE CAW030S1;
              zftota = zftota + zfamt;
              ENDIF;
           ENDDO;


Here is the code that loaded the information to the REXX queue in the first place. The program reads a subfile, and each record selected (a '1' in the field Z$OPT) will be pushed to the queue with the QREXQ API. It is a simple and fast method of passing a subset of data from one program to another, without writing and reading a file.


     D PutOnQueue      PR                  EXTPGM('QREXQ')
     D FUNT                           1
     D BUF                          128
     D BUFLEN                         9B 0
     D FLAG                           4B 0
     D RCODE                          4B 0

     D WAIVED        E DS                  extname(CAWCNFWF)

           IF SFLRCN > 0;
              FOR sflrec = 1 by 1 to sflrcn;
                 CHAIN sflrec CAW025S1;
                 IF z$opt = '1' AND zfrsnc > 0 and zfactn <> *blank;
                  CFOWN = Customer;         // owner
                  CFPRJ = tproj;            // project
                  CFACT = tacct;            // account
                  CFCNT = tcent;            // century
                  CFREF = tref;             // reference code
                  CFTRN = tcode;            // transaction code
                  CFAMT = zfamt;            // amount
                  CFDSC = tdesc;            // description
                  CFDUE = tduedt;           // due date
                  CFPCT = tbpct;            // bill percent
                  CFRSN = zfrsnc;           // reason code
                  CFDFI = zfactn;           // action, defer/immed
                  rxbuff = waived;          // copy waiver to buffer
                  rxfunc = 'A' ;
                  rxblen = 128 ;
                  rxflag = 1   ;
                  rxCode = 0   ;
                  //*------------------------------------------------
                  //* Push buffer to REXQ
                  //*------------------------------------------------
                  PutOnQueue(rxfunc: rxbuff: rxblen: rxflag: rxcode);
                 ENDIF;
              ENDFOR;
           ENDIF;