Executing JES operator commands from inside REXX.

This particular example takes the job number as input parameter and then issues the cancel command (C=J) to remove the job from JES.

/*REXX*/                                           
/*    */                                           
ARG JOBNUM                                         
IF JOBNUM = '' THEN RETURN                         
ADDRESS ISPEXEC                                    
                                                   
SIGNAL ON NOVALUE                                  
ADDRESS TSO                                        
                                                   
  'ALLOC FI(INTRDR) WRITER(INTRDR) SYSOUT(Y) REUSE'
  LIST.1 = '/*$TJ' || JOBNUM || ',C=J'             
  LIST.0 = 1                                       
  'EXECIO * DISKW INTRDR (FINIS STEM LIST.'        
  'FREE FI(INTRDR)'                                
RETURN                                             

Other examples:

Purge Job output: LIST.1 = '/*$PJ' || JOBNUM || ',PURGE'
Put Job on suspend: LIST.1 = '/*$TJ' || JOBNUM || ',C=S'
Change Job priority to 6: LIST.1 = '/*$TJ' || JOBNUM || ',P=6'

The example above is using the TSO address space to get things accomplished, but you can also use the MVS address space. The example below will cancel a userid from JES.

/* REXX */                                               
ARG ID
ADDRESS TSO 'ALLOCATE F(SUIRDR) SYSOUT(A) WRITER(INTRDR)'
ADDRESS MVS NEWSTACK                                     
QUEUE LEFT("/*$VS,'C U="ID"'",80)                        
QUEUE LEFT("XX  ",80)                                    
QUEUE ''                                                 
ADDRESS MVS 'EXECIO * DISKW SUIRDR (FINIS'               
ADDRESS MVS 'DELSTACK'                                   
ADDRESS TSO 'FREE F(SUIRDR)' 

Notes:
  • The security at your installation is going to determine if you would be able to execute these commands.


Reference: