Tip

Job status monitoring

If you use these programs you increase your "freedom". You do not have to check the active jobs every minute. Just submit the first CL program and it will send you a message when any job is in the specified status (MSGW, HLD etc.) The idea is not to only watch the job status. I think it is more. If you modify the program it can alert you, when a specified user signed on or a specified subsystem started etc.

- You do not have to use the WRKACTJOB in this program. If you use WRKCFGSTS you can monitor a LINE,CTL,DEV etc. when became active.

- The type of alert can be modified too. I use SNDDST to send an e-mail to my address at my mobile phone provider. I use a mail notification service and they send me an SMS when I get an e-mail. The SMS contains the subject of e-mail sent by the AS/400. It works fine. It is good thing, when I started a lot of jobs to run for the weekend and those have to finish by Monday morning. I can be sure there is no MSGW or HLD status! I use SNDBRKMSG when I'm in a computer room or in my workshop. Easy to hear a big beep if an MSGW occur while you use another application!

It is a simple solution for daily problems, made in CL without API-s and easy to understand. We have used this for about 3 years. It became a standard and helpful tool for us! If you have any questions about this tip, you can e-mail Jozsef Petrovszki. Additional tip: If you use serial jobq to run your jobs, submit an SNDDST or SNDBRKMSG command after the jobs and you will be notified when all your jobs finished!


 1st. Caller program: Compile to name ALERT
the code:

PGM        PARM(&STS)                                     
             DCL        VAR(&ERROR) TYPE(*CHAR) LEN(1)                 
             DCL        VAR(&STS) TYPE(*CHAR) LEN(4)                   
             DCL        VAR(&TXT) TYPE(*CHAR) LEN(60)                  
                                                                       
START:       OVRPRTF FILE(QPDSPAJB) HOLD(*YES)                         
             WRKACTJOB  OUTPUT(*PRINT)                                 
             DLTOVR FILE(QPDSPAJB)                                     
             CHKOBJ     OBJ(QTEMP/ALERTJOB) OBJTYPE(*FILE)             
             MONMSG     MSGID(CPF9801) EXEC(DO)                        
             CRTPF      FILE(QTEMP/ALERTJOB) RCDLEN(132)               
             ENDDO                                                     
             CPYSPLF    FILE(QPDSPAJB) TOFILE(QTEMP/ALERTJOB) +
                        SPLNBR(*LAST)                               
             DLTSPLF    FILE(QPDSPAJB) SPLNBR(*LAST)                  
                                                                      
             CALL       PGM(yourlib/ALERTW) PARM(&STS &ERROR &TXT)      
             IF         COND(&ERROR *EQ '1') THEN(DO)                 
             SNDDST TYPE(*LMSG) TOINTNET((yourname@yourmobilephoneprovider.com)) +
                        DSTD('alert') LONGMSG(B) SUBJECT(&TXT)                                  
             SNDBRKMSG  MSG(&TXT) TOMSGQ(DSP01 DSP02 DSP06 DSP07)     
             GOTO       CMDLBL(END)                                   
             ENDDO                                                    
             DLYJOB     DLY(180)                                      
             GOTO       CMDLBL(START)                                 
END:       ENDPGM 

2nd: Finder program: Compile to name ALERTW This program called by the first CL program (ALERT) Before you compile it you have to create a workfile in qtemp with CRTPF FILE(QTEMP/ALERTJOB) RCDLEN(132) command!

 
PGM PARM(&STS &ERROR &TXT)                                           
             DCL        VAR(&STS) TYPE(*CHAR) LEN(4)                 
             DCL        VAR(&ERROR) TYPE(*CHAR) LEN(1)               
             DCL        VAR(&TXT) TYPE(*CHAR) LEN(60)                
                                                                     
             DCLF       FILE(QTEMP/ALERTJOB)                         
             CHGVAR     VAR(&ERROR) VALUE('0')                       
READ:        RCVF       RCDFMT(ALERTJOB)                             
             MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))        
             IF         COND(%SST(&ALERTJOB 111 4) *EQ &STS) +       
                          THEN(DO)                                   
             CHGVAR     VAR(&ERROR) VALUE('1')                       
             CHGVAR     VAR(&TXT) VALUE(&STS *CAT ' status : ' *CAT +
                          %SST(&ALERTJOB 29 6) *CAT '/' *CAT +            
                          %SST(&ALERTJOB 17 10) *TCAT '/' *CAT +          
                          %SST(&ALERTJOB 4 10) *CAT '!!!')                
             ENDDO                                                        
             GOTO READ                                                    
END:         ENDPGM 

This was first published in July 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.