/* rexx */                                                                      
/*-------------------------------------------------------------------*/         
/*                                                                   */         
/*                         REXX Exec : DB2STAT                       */         
/*                                                                   */         
/*  Description : Displays the DB2 subsystems on the current LPAR    */         
/*                                                                   */         
/*  Created on : 4 Apr 2018                                          */         
/*  Created by : Kevin Ferguson                                      */         
/*             : Userid(MIT001)                                      */         
/*             : using ABBYDALE.XFER.REXX(DB2STAT)                   */         
/*                                                                   */         
/*  Called by :                                                      */         
/*                                                                   */         
/*  Calls :                                                          */         
/*                                                                   */         
/*  Change Activity :                                                */         
/*                                                                   */         
/*                ©Copyright of Abbydale Systems LLC.                */         
/*                                                                   */         
/*-------------------------------------------------------------------*/         
signal on halt         /* attention key      */                                 
numeric digits 10                                                               
cvt_ptr = get_ptr(10,)              /* CVT pointer            */                
cvtjesct = get_ptr(cvt_ptr,'128')   /* address of CVTJESCT    */                
ssct_ptr = get_ptr(cvtjesct,'18')   /* address of SSCT        */                
Block_id = get_data(ssct_ptr,'0',4) /* Block_id must = 'SSCT' */                
done = 'n'                                                                      
cc = 0                                                                          
do until done = 'y'                                                             
    if Block_id = 'SSCT' then do                                                
       taskname = get_data(ssct_ptr,'8',4)                                      
       SSCTSUSE_ptr = get_ptr(ssct_ptr,'14')                                    
       ssct_anc = get_ptr(cvtjesct,'18')                                        
       ssrc = get_data(SSCTSUSE_ptr,'70',1)                                     
       if ssctsuse_ptr = '0' then do                                            
          ssct_ptr = get_ptr(ssct_ptr,'4')                                      
       end                                                                      
       else do                                                                  
          if SSCTSUSE_ptr < '80000000' then do                                  
             ASIDname = get_data(SSCTSUSE_ptr,'c',8)                            
             ASIDSSRC = get_data(SSCTSUSE_ptr,'66',2)                           
             Program = get_data(SSCTSUSE_ptr,'54',7)                            
             Early = get_data(SSCTSUSE_ptr,'4',4)                               
             If early = "ERLY" then do                                          
                If program = 'DSN3EPX' then do                                  
                   run = get_ptr(ssct_ptr,'10',4)                               
                   run = get_ptr(run,'4',4)                                     
                   st = "*ACTIVE*"                                              
                   If run = '0' then do                                         
                       st = "INACTIVE"                                          
                   end                                                          
                   temp = st 'DB2 subsystem' taskname                           
                   temp = temp'('ASIDName') SSRC('ssrc')'                       
                   say temp                                                     
                end                                                             
             end                                                                
          end                                                                   
          ssct_ptr = get_ptr(ssct_ptr,'4')                                      
       end                                                                      
       if ssct_ptr = '0' then do                                                
       done = 'y'                                                               
       end                                                                      
 end                                                                            
 else do                                                                        
    Say 'Logic error ' block_id 'found where SSCT should be'                    
    cc = 16                                                                     
    done = 'y'                                                                  
 end                                                                            
end                                                                             
exit (cc)                                                                       
/*                         end of main line                           */        
get_ptr: procedure                                                              
/*                                                                              
returns a 4 byte pointer as hexadecimal string at address ADDR+OFFSET           
ADDR and OFFSET must be hex strings.                   */                       
 arg addr,offset                                                                
temp=d2x(x2d(addr)+x2d(offset))                                                 
return c2x(storage(temp,4))                                                     
exit                                                                            
get_data: procedure                                                             
/*                                                                              
returns LENGTH bytes att ADDR+OFFSET as an EBCDIC string.                       
ADDR and OFFSET must be hex strings.  LENGTH must be a                          
decimal string.                                                                 
*/                                                                              
arg addr,offset,length                                                          
temp=d2x(x2d(addr)+x2d(offset))                                                 
return storage(temp,length)                                                     
exit                                                                            
get_data2: procedure                                                            
/*                                                                              
returns LENGTH bytes att ADDR+OFFSET as an EBCDIC string.                       
ADDR and OFFSET must be hex strings.  LENGTH must be a                          
decimal string.                                                                 
*/                                                                              
arg addr,offset,length                                                          
temp=d2x(x2d(addr)+x2d(offset))                                                 
return storage(temp,length)                                                     
exit                                                                            
/*-------------------------------------------------------------------*/         
/*                        Trap HALT Condition                        */         
/*-------------------------------------------------------------------*/         
halt:                                                                           
say "HALT acknowledged in line" sigl                                            
say "Cleanup processing in progress"                                            
address "TSO"                                                                   
"delstack"                                                                      
exit(16)                                                                        
/*-------------------------------------------------------------------*/         
/*                           End of DB2STAT                          */         
/*-------------------------------------------------------------------*/      

