Auto refresh screen - Data queue style

Here's a different technique to auto refresh a screen.

This Content Component encountered an error

After looking at some recent post I would like to draw the attention of my honorable comrades (namely iSeries programmers) to a different technique to auto refresh a screen.

This technique uses a data queue as a mean to control the refresh timing. This approach is more flexible then using the WAITRCD technique since the timing can be controlled within the application.

You can find more info in the "CL Programming" V5R1 book check the "Examples Using a Data Queue".

The code is valid for previous versions (V4R4M0 for sure).

Compile instructions and sequence

1 - QDDSSRC.DEM03202 - OPTION(*NOLIST) RSTDSP(*YES) DFRWRT(*NO)
2 - QCLSRC.DEM03202P
3 - QRPGSRC.DEM03202


 
=======================================================================

QDDSSRC.DEM03202

     A* PARMS OPTION(*NOLIST) RSTDSP(*YES) DFRWRT(*NO)
     A                                      DSPSIZ(24 80 *DS3)
     A                                      PRINT
     A                                      ERRSFL
     A                                      CF03
     A          R PNL00N                    TEXT('Reference only')
     A            PNLCTL         2S 0H      TEXT('Panel control')
     A          R PNL02N
     A                                      OVERLAY
     A            PRCNAME       10A  O  1  2
     A                                  1 71DATE
     A                                      EDTCDE(Y)
     A            USRNAME       10A  O  2  2
     A                                  2 30' Data queue refresh '
     A                                      DSPATR(HI)
     A                                      DSPATR(UL)
     A                                  2 71TIME
     A          R PNL04N
     A                                      OVERLAY
     A                                 10 13'Data queue wait time.......'
     A            WATTIM         5Y 0B 10 42EDTCDE(M)
     A                                      COMP(NE 0)
     A                                      DSPATR(MDT)
     A                                 13 13'Data queue.................'
     A            DTQNAM        10A  O 13 42
     A            DTQLIB        10A  O 13 53
     A          R PNL04F
     A                                      OVERLAY
     A                                 23  2'F3=Exit'
     A                                      COLOR(BLU)
     A          R PNL06R                    SFL
     A            ENTLEN         5S 0H
     A            ENTDTA        78A  H
     A            OUTF          78A  O  6  2
     A          R PNL06C                    SFLCTL(PNL06R)
     A                                      SFLSIZ(0017)
     A                                      SFLPAG(0016)
     A                                      CF12
     A  75                                  INVITE
     A                                      FRCDTA
     A                                      OVERLAY
     A  41                                  SFLDSP
     A  42                                  SFLDSPCTL
     A  45                                  SFLCLR
     A N46                                  SFLEND(*MORE)
     A            C06TR          4S 0H      TEXT('Total records')
     A            C06AR          4S 0H      TEXT('Active record')
     A            C06DR          4S 0H      SFLRCDNBR
     A                                  4  2'Input:'
     A            INPF          70A  I  4  9
     A          R PNL06F
     A                                      OVERLAY
     A                                 23  2'F3=Exit'
     A                                      COLOR(BLU)
     A                                 23 12'F12=Cancel'
     A                                      COLOR(BLU)


=======================================================================

QCLSRC.DEM03202P

             PGM

             DCLF       FILE(DEM03202)

             CHGVAR     VAR(&DTQLIB) VALUE(QTEMP)
             CHGVAR     VAR(&DTQNAM) VALUE(UDTAQ)

             DLTDTAQ    DTAQ(&DTQLIB/&DTQNAM)
             MONMSG     MSGID(CPF2100)

             CRTDTAQ    DTAQ(&DTQLIB/&DTQNAM) MAXLEN(128) AUT(*ALL)

             /* Note the DTAQ parameter */
             OVRDSPF    FILE(DEM03202) DTAQ(&DTQLIB/&DTQNAM)

             CALL       PGM(DEM03202) PARM(&DTQNAM &DTQLIB)

             DLTDTAQ    DTAQ(&DTQLIB/&DTQNAM)
             MONMSG     MSGID(CPF0000)

             ENDPGM
             
=======================================================================     

      *
      *PARMS DBGVIEW(*SOURCE) INDENT('| ')
      *PARMS OPTION(*NOXREF *NOEXPDDS) OUTPUT(*PRINT)
      *
     H datedit(*ymd)
      *
     Fdem03202  cf   e             workstn infds(infd01)
     F                                     sfile(Pnl06r:c06ar)
      *
     Dinfd00          sds
     D prcName                       10    overlay(infd00:  1)
     D JobName                       10    overlay(infd00:244)
     D UsrName                       10    overlay(infd00:254)
     D JobNmbr                        6    overlay(infd00:264)
      *
     Dinfd01           ds
     D FunKey                         1    overlay(infd01:369)
      *
     D nl              c                   const(x'20')
     D ri              c                   const(x'21')
      *
     D fk01            c                   const(x'31')
     D fk03            c                   const(x'33')
     D fk12            c                   const(x'3C')
      *
      *
     D perfix          s              5
     D time            s               z
      *
     C     *entry        plist
     C                   parm                    dtqnam
     C                   parm                    dtqlib
      *
      * Start panel
     C                   eval      pnlctl = 04
      *
      * Set default
     C                   Eval      wattim = 4
      *
 B01 C                   dou       FunKey = Fk03
  01  *
 S02 C                   select
 C02 C                   when      pnlctl = 04
  02 C                   exsr      Sr04
 C02 C                   when      pnlctl = 06
  02 C                   exsr      Sr06
 E02 C                   EndSl
  01  *
 E01 C                   enddo
      *
     C                   eval      *inlr = *on
      *
      *====================================================
     C     sr04          begsr
      * Get preference from the user
      *
 B01 C                   dou       FunKey = Fk03
  01  *
  01 C                   write     Pnl00n
  01 C                   write     Pnl02n
  01 C                   write     Pnl04f
  01 C                   exfmt     Pnl04n
  01  *
 S02 C                   select
  02  *
 C02 C                   when      funkey = fk03                                CF03
  02  *
 O02 C                   Other
  02  *
  02 C                   call      'QCLRDTAQ'
  02 C                   parm                    dtqnam
  02 C                   parm                    dtqlib
  02  *
  02  * Next panel
  02 C                   Eval      pnlctl = 06
  02  *
  02 C                   Leave
  02  *
 E02 C                   EndsL
  01  *
 E01 C                   enddo
      *
     C                   endsr
      *====================================================
     C     sr06          begsr
      *
 B01 C                   dou       FunKey = Fk03
  01  *
  01  * Set subfile indicators (Display)
  01 C                   eval      *in41 = c06tr > *zeros
  01 C                   eval      *in42 = *on
  01 C                   eval      *in45 = *off
  01  *
  01  * Turn Invite on
  01 C                   Eval      *IN75 = *On
  01  *
  01 C                   write     Pnl00n
  01 C                   write     Pnl02n
  01 C                   write     Pnl06f
  01 C                   write     Pnl06c
  01  *
  01  * Data Queue wait
  01 C                   exsr      sr0606
  01  *
 S02 C                   Select
  02  *
  02  * Time to refresh
 C02 C                   When      perfix <> '*DSPF'
  02  *
  02 C                   time                    time
  02 C                   eval      outf = ri + %char(time) + nl
  02  * Add line
  02 C                   Exsr      Sr0614
  02  *
 O02 C                   Other
  02  *
  02  * Entry is from display
  02  *
  02  * Turn Invite off
  02 C                   Eval      *IN75 = *Off
  02  *
  02  * Get the data from the file
  02 C                   read      Pnl06c
  02  *
 S03 C                   select
 C03 C                   when      funkey = fk03
 C03 C                   when      funkey = fk12
  03 C                   eval      pnlctl = 04
  03 C                   Leave
  03  *
 O03 C                   Other
  03  *
  03  * Process input data from display file
  03  * (in this case just write it to the subfile)
  03 C                   eval      Outf = Inpf
  03  * Add line
  03 C                   Exsr      Sr0614
  03  *
 E03 C                   endsl
  02  *
 E02 C                   endsl
  01  *
 E01 C                   enddo
      *
     C                   endsr
      *-------------------------
     C     sr0606        begsr
      * Data Queue wait
      *
     C                   eval      perfix = *blanks
      *
 B01 C                   dou       entlen = *zeros
  01  *
  01 C                   call      'QRCVDTAQ'
  01 C                   parm                    dtqnam
  01 C                   parm                    dtqlib
  01 C                   parm                    entlen
  01 C                   parm                    entdta
  01 C                   parm                    wattim
  01  *
 B02 C                   if        entlen = *zeros
  02 C                   leave
 E02 C                   endif
  01  *
  01 C                   Eval      perfix = %subst(entdta:1:5)
  01  *
  01  * Entry is from display
 B02 C                   if        perfix = '*DSPF'
  02  *
  02 C                   call      'QCLRDTAQ'
  02 C                   parm                    dtqnam
  02 C                   parm                    dtqlib
  02  *
  02 C                   leave
  02  *
 E02 C                   endif
  01  *
 E01 C                   enddo
      *
     C                   endsr
      *-------------------------
     C     sr0614        begsr
      * Add line
      *
      * Clear SFL if too many records
 B01 C                   if        c06tr = 16
  01  *
  01 C                   eval      *in41 = *off
  01 C                   eval      *in42 = *off
  01 C                   eval      *in45 = *on
  01  *
  01 C                   eval      c06tr = 0
  01 C                   eval      c06ar = 0
  01 C                   eval      c06dr = 1
  01  *
  01 C                   write     Pnl06c
  01  *
 E01 C                   EndIf
      *
     C                   eval      c06tr = c06tr + 1
     C                   eval      c06ar = c06tr
     C                   eval      c06dr = c06tr
      *
     C                   Eval      outf = %editc(c06ar:'Z') + ' : ' +
     C                                    %trim(outf)
      *
     C                   write     Pnl06r
      *
     C                   EndSr
      *====================================================
This was first published in October 2002

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchEnterpriseLinux

SearchDataCenter

Close