News Stay informed about the latest enterprise technology news and product updates.

Batch job code

Batch job code

 
                                                       
Routing entry sequence number . . . . . . . :   9998   
Program . . . . . . . . . . . . . . . . . . :   CHEATER
  Library . . . . . . . . . . . . . . . . . :     QGPL 
Class . . . . . . . . . . . . . . . . . . . :   QBATCH 
  Library . . . . . . . . . . . . . . . . . :     QGPL 
Maximum active routing steps  . . . . . . . :   *NOMAX 
Pool identifier . . . . . . . . . . . . . . :   1      
Compare value . . . . . . . . . . . . . . . :   'QCMDB'
                                                       
Compare start position  . . . . . . . . . . :   1   

The "CHEATER" program referenced in this routing entry, intercepts the request, sends an entry to the system audit journal and a message to the system administrators. It then lets the job run, after all, I am a nice guy... I don't want to cancel their job even though "I could have".

The impatient user does get a phone call from me so they can explain why it was so important to route a batch job to one of our interactive subsystems though! After they realize I'm watching, their behavior usually changes.

Here is the source for my "CHEATER" program:

 
/* ************************************************************** */ 
/* PROGRAM DESCRIPTION :                                          */ 
/*                                                                */ 
/* THIS PROGRAM IS CALLED WHEN A BATCH JOB IS STARTED IN          */ 
/* A NON BATCH SUBSYSTEM. IT REQUIRES A ROUTING ENTRY IN ANY      */ 
/* SUBSYSTEM YOU WISH TO MONITOR  COMPARE VALUE = QCMDB           */ 
/*                                                                */ 
/* SPECIAL COMPILE OPTIONS:                                       */ 
/*                                                                */ 
/*           WRITTEN BY: KEN GRAAP 09/22/99                       */ 
/*                                                                */ 
/* ************************************************************** */ 
             PGM                                                     
/* ************************************************************** */ 
/*                                                                */ 
/* DECLARE PROGRAM VARIABLES                                      */   
/*                                                                */   
/* ************************************************************** */   
             DCL        VAR(&JOB) TYPE(*CHAR) LEN(10)                  
             DCL        VAR(&USER) TYPE(*CHAR) LEN(10)                 
             DCL        VAR(&NUMBER) TYPE(*CHAR) LEN(6)                
             DCL        VAR(&JOBTYP) TYPE(*CHAR) LEN(1)                
             DCL        VAR(&JOBQ) TYPE(*CHAR) LEN(10)                 
             DCL        VAR(&SBSD) TYPE(*CHAR) LEN(10)                 
             DCL        &ERRORSW *LGL                     /* Std err */
             DCL        &MSGID *CHAR LEN(7)               /* Std err */
             DCL        &MSGDTA *CHAR LEN(100)            /* Std err */
             DCL        &MSGF *CHAR LEN(10)               /* Std err */
             DCL        &MSGFLIB *CHAR LEN(10)            /* Std err */
/* ************************************************************** */   
/*                                                                */   
/* GLOBAL MESSAGE MONITOR                                         */   
/*                                                                */   
/* ************************************************************** */   
             MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(STDERR1))      
/* ************************************************************** */  
/*                                                                */  
/* NOTIFY SYS ADMIN'S THEN PROCESS JOB                            */  
/*                                                                */  
/* ************************************************************** */  
                                                                      
             ADDLIBLE   LIB(TAATOOL) POSITION(*LAST)                  
             MONMSG     MSGID(CPF2103)                                
                                                                      
             RTVJOBA    JOB(&JOB) USER(&USER) NBR(&NUMBER)            
             RTVJOBSTRA JOBTYP(&JOBTYP) JOBQ(&JOBQ) SBSD(&SBSD)       <--
TAATOOL
                                                                      
             SAE        ID(CHEATER) ENTDTA(JOB_TYPE *BCAT &JOBTYP +   <--
CMD that sends
                          *BCAT JOBQ *BCAT &JOBQ *BCAT SBSD *BCAT +
an entry to the
                          &SBSD *BCAT ' JOB was submitted to a non +
system audit jrn.
                          batch subsystem')                           
                                                                      
             SNDPGMMSG  MSG('CHEATER Monitor entry created... Use +   
                          QSNDAUD command to view it...') TOUSR(KEG)  
             SNDPGMMSG  MSG('CHEATER Monitor entry created... Use +   
                          QSNDAUD command to view it...') TOUSR(KKH)
  
             TFRCTL     PGM(QCMD)                                     <--
Let the job run.                                     
/* ************************************************************** */  
/*                                                                */  
/* NORMAL END OF PROGRAM                                          */  
/*                                                                */  
/* ************************************************************** */  
 END:        RETURN                                                   
/* ************************************************************** */  
/*                                                                */  
/* STANDARD ERROR PROCESSING                                      */  
/*                                                                */  
/* ************************************************************** */  
 STDERR1:               /* Standard error handling routine */         
             IF         &ERRORSW SNDPGMMSG MSGID(CPF9999) +           
                          MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* Func chk *
             CHGVAR     &ERRORSW '1' /* Set to fail ir error occurs */
 STDERR2:    RCVMSG     MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) +
                          MSGF(&MSGF) MSGFLIB(&MSGFLIB)               
             IF         (&MSGID *EQ '       ') GOTO STDERR3           
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +           
                          MSGDTA(&MSGDTA) MSGTYPE(*DIAG)               
             GOTO       STDERR2 /* Loop back for addl diagnostics */   
 STDERR3:    RCVMSG     MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) + 
                          MSGF(&MSGF) MSGFLIB(&MSGFLIB)                
             SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +           
                          MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)             
             ENDPGM     

This program can be modified to take whatever action you feel is appropriate.

Dig Deeper on iSeries programming commands

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close