星期二, 10月 31, 2023

2001-08-20 如何於 RPG 中取得工作站狀態?(利用 Retrieve Configuration Status (QDCRCFGS) API)


如何於 RPG 中取得工作站狀態?(利用 Retrieve Configuration Status (QDCRCFGS) API)


File   : QRPGLESRC
Member : RTVCFGSTSR
Type   : RPGLE

Usage  : CRTBNDRPG PGM(RTVCFGSTSR) SRCFILE(XXX/xxx) DBGVIEW(*LIST)
         run with:  CALL RTVCFGSTSR PARM('*DEVD' 'DSP01')  (or whatever you like)

     H DFTACTGRP(*NO) ACTGRP(*NEW) OPTION(*SRCSTMT)

     D RtvCfgSts       PR                  ExtPgm('QDCRCFGS')
     D  RcvVar                    32766A   options(*varsize)
     D  RcvVarLen                    10I 0 const
     D  Format                        8A   const
     D  CfgDType                     10A   const
     d  CfgDName                     10A   const
     D  ErrorCode                 32766A   options(*varsize)

     D p_ds1           S               *
     D ds1             DS                  based(p_ds1)
     D  ds1BytesRtn                  10I 0
     D  ds1BytesAvl                  10I 0
     D  ds1Status                    10I 0
     D  ds1DateRtv                    7A
     D  ds1TimeRtv                    6A
     D  ds1StatusTxt                 20A
     D  ds1JobName                   10A
     D  ds1JobUser                   10A
     D  ds1JobNbr                     6A
     D  ds1PassThr                   10A
     D  ds1Reserv1                    3A
     D  ds1OffActCnv                 10I 0
     D  ds1NbrActCnv                 10I 0
     D  ds1LenActCnv                 10I 0
     D  ds1OffMulJob                 10I 0
     D  ds1NbrMulJob                 10I 0
     D  ds1LenMulJob                 10I 0

     D p_ds2           S               *
     D ds2             DS                  based(p_ds2)
     D  ds2CnvSts                    10I 0
     D  ds2CnvStsTxt                 20A
     D  ds2CnvStsMod                 10A
     D  ds2CnvStsJob                 10A
     D  ds2CnvStsUsr                 10A
     D  ds2CnvStsNbr                  6A

     D p_ds3           S               *
     D ds3             DS                  based(p_ds3)
     D  ds3MultJob                   10A
     D  ds3MultUser                  10A
     D  ds3MultNbr                    6A

     D dsEC            DS
     D  dsECBytesP             1      4I 0 inz(256)
     D  dsECBytesA             5      8I 0 inz(0)
     D  dsECMsgID              9     15
     D  dsECReserv            16     16
     D  dsECMsgDta            17    256

     D p_workspace     S               *
     D workspace       S              1A   based(p_workspace)
     D size            S             10I 0
     D Msg             S             52A
     D X               S             10I 0
     D pause           S              1A

     c     *entry        plist
     c                   parm                    CfgType          10
     c                   parm                    CfgName          10

     c                   eval      *inlr = *on

     C* Reserve space for up to 200 active convs & 200 multjobs...
     c                   eval      size = %size(ds1) + (%size(ds2)*200) +
     c                                 (%size(ds3)*200)
     c                   alloc     size          p_workspace

     C* Call Retrieve Cfg Status API:
     c                   callp     RtvCfgSts(workspace: size: 'CFGS0100':
     c                                CfgType: CfgName: dsEC)
     c                   if        dsECBytesA > 0
     c                   eval      Msg = 'QDCRCFGS failed with ' +
     c                                 dsECMsgID
     c                   dsply                   Msg
     c                   return
     c                   endif

     c                   eval      p_ds1 = p_workspace

     C** Show status of cfg descr:
     c                   eval      Msg = 'Status = ' + ds1StatusTxt
     c     Msg           dsply

     C** Show job using cfg descr:
     c                   if        ds1JobName <> *blanks
     c                   eval      Msg = 'Job = ' + %trimr(ds1JobName) +
     c                                  '/' + %trimr(ds1JobUser) + '/' +
     c                                  ds1JobNbr
     c     Msg           dsply
     c                   endif

     C** Show any active conversations:
     c                   do        ds1NbrActCnv  X
     c                   eval      p_ds2 = p_workspace + ds1OffActCnv +
     c                               ((X-1) * ds1LenActCnv)
     c                   eval      Msg = 'ActCnv ' + %trim(%editc(X:'Z'))
     c                              + ' status = ' + ds2CnvStsTxt
     c     Msg           dsply
     c                   eval      Msg = 'ActCnv ' + %trim(%editc(X:'Z')) +
     c                              ' job = ' + %trimr(ds2CnvStsJob) +
     c                              '/' + %trimr(ds2CnvStsUsr) + '/' +
     c                              ds2CnvStsNbr
     c     Msg           dsply
     c                   enddo

     C** If this device can be used by multiple jobs,
     C**  show them all now:
     c                   do        ds1NbrMulJob  X
     c                   eval      p_ds2 = p_workspace + ds1OffMulJob +
     c                               ((X-1) * ds1LenMulJob)
     c                   eval      Msg = 'MultJob ' + %trim(%editc(X:'Z')) +
     c                              ' = ' + %trimr(ds3MultJob) +
     c                              '/' + %trimr(ds3MultUser) + '/' +
     c                              ds3MultNbr
     c     Msg           dsply
     c                   enddo

     c                   dsply                   pause

     c                   return

      


Retrieve Configuration Status (QDCRCFGS) API參考資訊

https://www.ibm.com/docs/api/v1/content/ssw_ibm_i_75/apis/QDCRCFGS.htm

沒有留言: