星期二, 10月 31, 2023

2001-03-16 如何於程式中判斷 Subsystem 的狀態 ?


如何於程式中判斷 Subsystem 的狀態 ?

/***********************************************************************/
/*                                                                     */
/* RTVSBSSTS command 的使用範例程式 CLP : RTVSBSSTSC                   */
/*                                                                     */
/* 呼叫這隻程式並且傳 subsystem 名稱及 libary 名稱當參數.              */
/* 這隻程式會顯示 subsystem 是否啟動及有多少 Jobs 在此 subsyste中執行  */
/*                                                                     */
/***********************************************************************/
     PGM        PARM(&NAME &LIB)                               
            DCL        VAR(&NAME) TYPE(*CHAR) LEN(10)                 
            DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)                  
            DCL        VAR(&STATUS) TYPE(*CHAR) LEN(10)               
            DCL        VAR(&JOBSN)  TYPE(*DEC) LEN(7 0)               
            DCL        VAR(&JOBSC)  TYPE(*CHAR) LEN(7)                
            RTVSBSSTS  SBSNAME(&LIB/&NAME) STATUS(&STATUS) +          
                         #ACTJOBS(&JOBSN)                             
            CHGVAR     VAR(&JOBSC) VALUE(&JOBSN)                      
            SNDPGMMSG  MSGID(CPF9898) MSGF(QCPFMSG) +                 
                         MSGDTA('Subsystem: ' *CAT &NAME *BCAT ' +    
                         Library: ' *BCAT &LIB *BCAT ' Status: ' +    
                         *BCAT &STATUS *BCAT ' #ActiveJobs:' +        
                         *BCAT &JOBSC) TOMSGQ(*TOPGMQ) MSGTYPE(*COMP) 
            ENDPGM                                                     



      *=============================================================== 
      *                                                                      
      * Program:    RTVSBSSTSR - CPP for Retrieve Subsystem Status           
      *
      * Type   :    RPGLE
      *                                                                 
      * Purpose:    When passed the name of a subsystem, return parms        
      *             showing *ACTIVE/*INACTIVE and the number of jobs         
      *                                                                      
      *                                                                      
      *=============================================================== 
                                                                        
      *---------------------------------------------------------------------  
      * Parameters                                                           
      *--------------------------------------------------------------------- 
     d PSbsLib         s             20                                      
     d PStatus         s             10                                      
     d P#jobs          s              7  0                                   
                                                                        
      *--------------------------------------------------------------------- 
      * Miscellaneous variables and structures                               
      *--------------------------------------------------------------------- 
     d arcvr           ds            80                                      
     d   aStatus              29     38                                      
     d   a#jobs               73     76B 0                                   
     d arcvrlen        s              4b 0 inz(80)                           
     d aformat         s              8    inz('SBSI0100')                   
     d aqualname       s             20                                      
     d aerror          s             10                                      
     d NotFound        c                   Const('*NOTFOUND')                
                                                                         
      *--------------------------------------------------------------------- 
      *                                                                      
      * Parameter List                                                       
      *                                                                      
      *--------------------------------------------------------------------- 
     c     *Entry        PList                                               
     c                   Parm                    PSbsLib                     
     c                   Parm                    PStatus                     
     c                   Parm                    P#Jobs                      
                                                                        
      *--------------------------------------------------------------------- 
      *                                                                      
      * Mainline                                                             
      *                                                                      
      *--------------------------------------------------------------------- 
     c                   eval      aqualname = PsbsLib                       
     c                   CALL      'QWDRSBSD'                                
     c                   PARM                    arcvr                       
     c                   PARM                    arcvrlen                    
     c                   PARM                    aformat                     
     c                   PARM                    aqualname                   
     c                   PARM                    aerror                      
     c                   if        aStatus = *blanks                         
     c                   eval      PStatus   = NotFound                      
     c                   eval      P#Jobs    = *zero                         
     c                   else                                                
     c                                                                       
     c                   eval      PStatus   = AStatus            
     c                   eval      P#Jobs    = A#jobs             
     c                   endif                                    
     c                   eval      *inlr = *on                    
     c                   return                                   

/*==============================================================*/  
/*                                                              */  
/* Command:    RTVSBSSTS -- RETRIEVE SUBSYSTEM STATUS           */  
/*                                                              */  
/* Type   :    CMD                                              */  
/*                                                              */  
/*==============================================================*/  
 RTVSBSSTS:  CMD        PROMPT('Retrieve Subsystem Status')             
             PARM       KWD(SBSNAME) TYPE(SBSNAMLIB) MIN(1) +           
                          PROMPT('Subsystem')                           
             PARM       KWD(STATUS) TYPE(*CHAR) LEN(10) RTNVAL(*YES) +  
                          PROMPT('Subsystem Status (Char 10)')          
                          PROMPT('Subsystem Status (Char 10)')          
             PARM       KWD(#ACTJOBS) TYPE(*DEC) LEN(7 0) +             
                          RTNVAL(*YES) PROMPT('# Active jobs (Dec 7 +   
                          0)')                                          
  SBSNAMLIB:  QUAL       TYPE(*NAME) LEN(10) MIN(1)                      
                                                                        
             QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +                
                          SPCVAL((*LIBL) (*CURLIB)) PROMPT('Library')   


      


安裝步驟:


1. CRTBNDRPG PGM(lib/RTVSBSSTSR) SRCFILE(lib/QRPGLESRC) SRCMBR(RTVSBSSTSR)


2. CRTCMD CMD(lib/RTVSBSSTS) PGM(lib/RTVSBSSTSR) ALLOW(*IPGM *BPGM)


3. CRTCLPGM PGM(lib/RTVSBSSTSC) SRCFILE(lib/QCLSRC) SRCMBR(RTVSBSSTSC)


4. 於命令列下 ==> CALL RTVSBSSTSC ('QINTER'  '*LIBL')

沒有留言: