     **
     **  Program summary
     **  ---------------
     **
     **  Message handling API:
     **    QGYOLJBL      Open list of joblog   Lists messages from the specified
     **                  messages              job's joblog in sending data and
     **                                        time order. Replies to inquiry-
     **                                        messages are listed immediately
     **                                        after the message it is associated
     **                                        with.
     **
     **                                        The QGYOLJBL API is found in the
     **                                        QGY library as are all other open
     **                                        list APIs.
     **
     **                                        To retrieve open lists entries
     **                                        from an already open list the
     **                                        QGYGTLE (Get List Entries) API
     **                                        is available.
     **
     **    QGYCLST       Close list            This API closes the previously
     **                                        opened list identified by the
     **                                        request handle parameter.
     **                                        Storage allocated is freed.
     **
     **  Sequence of events:
     **    1. The API input parameters are initialized
     **
     **    2. The open list of joblog messages API is called
     **
     **    3. If an error occurred calling the API or
     **       no entry is found blanks are returned to
     **       the caller
     **
     **    4. The requested joblog message text is
     **       retrieved and returned to the caller.
     **
     **
     **  Parameters:
     **    PxJobId     INPUT      Qualified job name of the job whose joblog
     **                           messages are to be listed. The following
     **                           format applies:
     **
     **                            1-10  Char 10   Job name
     **                           11-20  Char 10   Job user
     **                           21-26  Char  6   Job number
     **
     **                           The special value '*' is allowed. This value
     **                           identifies the current job.
     **
     **    PxMsgOpt    INPUT      List message option. The following special
     **                           values are allowed:
     **
     **                           *FIRST   Retrieve the first (oldest) message
     **                           *LAST    Retrieve the last (newest) message
     **                           *NEXT    Retrieve the message following the
     **                                    one identified by PxMsgKey.
     **                           *PRV     Retrieve the message previous to
     **                                    the one identified by PxMsgKey.
     **
     **    PxMsgKey    INPUT      Optional parameter holding the message key
     **                           value used to position the list prior to the
     **                           retrieval of the message requested by the
     **                           PxMsgOpt parameter's relative special values.
     **
     **    Return-     OUTPUT     Joglog message text. Other available message
     **    value                  attributes could be added to or replace this
     **                           value.
     **
     **  Programmer's note:
     **    As mentioned above library QGY must be in the job library list
     **    to succesfully run this program.
     **
     **    To list another user's joblog *JOBCTL special authority is
     **    required.
     **
     **    To list the joblog of a user having user class *SECOFR, special
     **    authority *ALLOBJ is required.
     **
     **
     **  Compile options:
     **
     **   CrtRpgMod  Module( CBX007 )
     **   CrtSrvPgm  Srvpgm( CBX007 )  Module( CBX007 )  Export( *ALL )
     **
     **
     **-- Control spec:  -----------------------------------------------------**
     H NoMain  Option( *SrcStmt )
     **-- API error data structure:  -----------------------------------------**
     D ApiError        Ds
     D  AeBytPrv                     10i 0 Inz( %Size( ApiError ))
     D  AeBytAvl                     10i 0
     D  AeExcpId                      7a
     D                                1a
     D  AeExcpDta                   128a
     **-- Get joblog message:  -----------------------------------------------**
     D GetLogMsg       Pr           512a   Varying
     D  PxJobId                      26a   Const
     D  PxMsgOpt                      6a   Const
     D  PxMsgKey                      4a   Options( *NoPass )
     **-- Get joblog message:  -----------------------------------------------**
     P GetLogMsg       B                   Export
     D                 Pi           512a   Varying
     D  PxJobId                      26a   Const
     D  PxMsgOpt                      6a   Const
     D  PxMsgKey                      4a   Options( *NoPass )
     **-- API parameters:  ---------------------------------------------------**
     D JlMsgInfLen     s             10i 0 Inz( %Size( JlMsgInf ))
     D JlSltInfLen     s             10i 0 Inz( %Size( JlSltInf ))
     D JlGetRcdNbr     s             10i 0
     D JlRtnRcdNbr     s             10i 0
     **
     D JlSltInf        Ds
     D  SiRtvDrc                     10a
     D  SiJobId                      26a   Inz( '*' )
     D  SiIntJobId                   16a
     D  SiStrKey                      4a
     D  SiStrKeyN                    10i 0 Overlay( SiStrKey )
     D  SiMsgLenMax                  10i 0 Inz( -1 )
     D  SiHlpLenMax                  10i 0 Inz( 0 )
     D  SiFldIdsOfs                  10i 0 Inz( 84 )
     D  SiFldIdsNbr                  10i 0 Inz( %Elem( SiFldIds ))
     D  SiCalMsqOfs                  10i 0 Inz( 88 )
     D  SiCalMsqLen                  10i 0 Inz( 1 )
     D                                4a
     D  SiFldIds                     10i 0 Dim( 1 ) Inz( 302 )
     D  SiCalMsq                     10a   Inz( '*' )
     **
     D JlLstInf        Ds
     D  LiRcdNbrTot                  10i 0
     D  LiRcdNbrRtn                  10i 0
     D  LiHandle                      4a
     D  LiRcdLen                     10i 0
     D  LiInfSts                      1a
     D  LiDts                        13a
     D  LiLstSts                      1a
     D                                1a
     D  LiInfLen                     10i 0
     D  LiRcd1                       10i 0
     D                               40a
     **
     D JlMsgInf        Ds
     D  MiNxtMsgOfs                  10i 0
     D  MiFldDtaOfs                  10i 0
     D  MiFldNbrOfs                  10i 0
     D  MiMsgSev                     10i 0
     D  MiMsgId                       7a
     D  MiMsgTyp                      2a
     D  MiMsgKey                      4a
     D  MiMsgF                       10a
     D  MiMsgFlib                    10a
     D  MiDatSnt                      7a
     D  MiTimSnt                      6a
     D  MiFldDta                  32767a
     **
     D JlFldDta        Ds                  Based( pJlFldDta )
     D  FdNxtFldOfs                  10i 0
     D  FdFldDtaLen                  10i 0
     D  FdFldId                      10i 0
     D  FdDtaTyp                      1a
     D  FdDtaSts                      1a
     D                               14a
     D  FdDtaLen                     10i 0
     D  FdDta                      1024a
     **
     **-- Get joblog message:  -----------------------------------------------**
     **
     C                   Eval      SiJobId     =  PxJobId
     C                   Eval      SiStrKey    = x'00000000'
     **
     C                   Select
     C                   When      PxMsgOpt    = '*FIRST'
     C                   Eval      SiRtvDrc    = '*NEXT'
     **
     C                   When      PxMsgOpt    = '*LAST '
     C                   Eval      SiRtvDrc    = '*PRV '
     C                   Eval      SiStrKey    = x'FFFFFFFF'
     **
     C                   When      PxMsgOpt    = '*NEXT '      Or
     C                             PxMsgOpt    = '*PRV  '
     C                   Eval      SiRtvDrc    = PxMsgOpt
     **
     C                   If        %Parms      = 3
     C                   Eval      SiStrKey    = PxMsgKey
     C                   EndIf
     C                   EndSl
     **
     C                   Select
     C                   When      PxMsgOpt    = '*NEXT '
     C                   Eval      SiStrKeyN   = SiStrKeyN + 1
     **
     C                   When      PxMsgOpt    = '*PRV  '
     C                   Eval      SiStrKeyN   = SiStrKeyN - 1
     C                   EndSl
     **
     C                   Call      'QGYOLJBL'
     C                   Parm                    JlMsgInf
     C                   Parm                    JlMsgInfLen
     C                   Parm                    JlLstInf
     C                   Parm      1             JlGetRcdNbr
     C                   Parm                    JlSltInf
     C                   Parm                    JlSltInfLen
     C                   Parm                    ApiError
     **
     C                   If        AeBytAvl    = *Zero         And
     C                             LiRcdNbrRtn > *Zero
     C                   Eval      pJlFldDta   = %Addr( JlMsgInf ) + MiFldDtaOfs
     **
     C                   If        %Parms      = 3
     C                   Eval      PxMsgKey    = MiMsgKey
     C                   EndIf
     **
     C                   Else
     C                   Return    *Blanks
     C                   EndIf
     **
     C                   Call      'QGYCLST'
     C                   Parm                    LiHandle
     C                   Parm                    ApiError
     **
     C                   Return    FdDta
     **
     P GetLogMsg       E
