This program illustrates the use of the "Open List" APIs

This program illustrates the use of the "Open List" APIs

This program illustrates the use of the "Open List" APIs that allows you generate lists asynchronously. That is,...

instead of generating lists to a user space, a server job generates the list internally and in the background letting your application execute simultaneously. When your app needs one of the items from the list, it calls an API to return it.

Note, only some of the list APIs are supported. The general procedure is:

1. Call the special version of the list API to start a server job that builds the list in the background.

2. Call an API to receive from the server job an item from the list.

3. Repeat step 2 as needed to receive other items or to re-receive items.

4. Close the list. This cleans up the server job by freeing its internal storage. The server job can then be used to process another open list.


     d #IgnoreErr      c                   Const(x'0000000800000000')
     d #ResendErr      c                   Const(x'0000000000000000')

     d RcvrLen         s             10i 0 Inz(0)

     d SelectDS        ds
     d   Direction                   10    Inz('*NEXT')
     d   QJobName                    26    Inz('*')
     d   IntJobID                    16
     d   StartKey                     4    Inz(x'00000000')
     d   MaxMsgLen                   10i 0 Inz(-1)
     d   MaxHelpLen                  10i 0 Inz(0)
     d   OSFieldIDs                  10i 0 Inz(84)
     d   NbrFldIDs                   10i 0 Inz(%Elem(FldIDArr))
     d   OSCallMsgQ                  10i 0 Inz(88)
     d   LenCalMsgQ                  10i 0 Inz(1)
     d   FldIDArr             85     88b 0 Dim(1) Inz(302)
     d   CallMsgQ             89     90    Inz('*')

     d LenSelctDS      s             10i 0 Inz(%Size(SelectDS))

     d ListInfoDS      ds
     d   TotalRecs                   10i 0
     d   RecsRtrnd                   10i 0
     d   Handle                       4
     d   RecLength                   10i 0
     d   InfoComplt                   1
     d   DateTime                    13
     d   ListStatus                   1
     d                                1
     d   InfoLength                  10i 0
     d   FirstRec                    10i 0
     d                               40

     d Recs2Rtrn       s             10i 0
     d Rec#2Rtrn       s             10i 0

     d MsgEntry        ds
     d   OSNextMsg             1      4b 0
     d   OSFields              5      8b 0
     d   OSNbrFlds             9     12b 0
     d   MsgSev               13     16b 0
     d   MsgID                        7
     d   MsgType                      2
     d   MsgKey                       4
     d   MsgFile                     10
     d   MsgFileLib                  10
     d   DateSent                     7
     d   TimeSent                     6
     d   EntryArr              1  32767    Dim(32767)

     d EntryFlds       ds                  Based(pEntryFlds)
     d   OSNextFld             1      4b 0
     d   LenFldInfo            5      8b 0
     d   FieldID               9     12b 0
     d   TypeOfData                   1
     d   StsOfData                    1
     d                               14
     d   LenOfData                   10i 0
     d   Data                     32000
     d   FieldsArr             1  32767    Dim(32767)

      *  Start server job to generate job log messages in the
      *  background (ie, asynchronously). API QGYOLJBL is the
      *  sepcial version of the QMHLJOBL API.
     c                   Call      'QGYOLJBL'
     c                   Parm                    Rcvr              1
     c                   Parm      0             RcvrLen
     c                   Parm                    ListInfoDS
     c                   Parm      0             Recs2Rtrn
     c                   Parm                    SelectDS
     c                   Parm                    LenSelctDS
     c                   Parm      #ResendErr    Error             8

      *  At this point, the program can do something else while the list
      *  is being generated in the background, or it can begin processing 
      *  the list immediately.

      *  Process list of messages.

     c                   Eval      Rec#2Rtrn = 1
     c                   DoW       ListStatus <> '2'  or
     c                             Rec#2Rtrn <= TotalRecs

      *            Get a message.

     c                   Eval      RcvrLen = %Size(MsgEntry)
     c                   DoU       RecsRtrnd > 0
     c                   Call      'QGYGTLE'
     c                   Parm                    MsgEntry
     c                   Parm                    RcvrLen
     c                   Parm                    Handle
     c                   Parm                    ListInfoDS
     c                   Parm      1             Recs2Rtrn
     c                   Parm                    Rec#2Rtrn
     c                   Parm      #ResendErr    Error             8
     c                   EndDo

      *    Point pEntryFlds to the beginning of the fields for
      *    the current message.
     c                   Eval      pEntryFlds = %Addr(EntryArr(OSFields+1))

      *    Display message.
     c                   If        LenOfData > 50
     c                   Z-Add     50            m                 5 0
     c                   Else
     c                   Z-Add     LenOfData     m
     c                   EndIf

     c     m             Subst(P)  Data          MsgDsply         50
     c     MsgDsply      Dsply                   r                 1

     c                   Eval      Rec#2Rtrn = Rec#2Rtrn + 1
     c                   EndDo

      *  Close list (ie, cleanup server job).
     c                   Call      'QGYCLST'
     c                   Parm                    Handle
     c                   Parm      #ResendErr    Error             8

     c                   MoveL     '1'           *InLR
     c                   Return

This was last published in January 2006



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: