Home > AS/400 Tips > iSeries programmer tips > Monitor your job
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

Monitor your job


John Kohan, Search400.com expert
07.02.2003
Rating: -4.05- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Want to know when a batch job is in a "MSGW" (Message Wait) status in QBATCH? You could place message monitors in CL programs to trap those messages and take the appropriate action. But unfortunately, that can't always be accomplished. Several different developer processes may run on any given iSeries. Those include in-house processes, outside vendors, and even IBM processes.

You may, however, monitor your system for MSGW jobs with just a few simple lines of code. The process is simple, and I have used it in the past with good success.

The WRKACTJOB command allows you to display any subsystem you wish. By using the SBS keyword, you can specify one or more subsystems to list. In addition, you may list those subsystems to screen or to a spool file.


John Kohan

By listing the subsystems to a spool file, you can copy the spool file to a physical file and read them with a RPG program. The RPG program can look at the status of each job and take the necessary action.

I have included a very simple CL and RPG program. They are intended to give you a starting point from which to build a process. You will want to add additional code to do such things as properly remove the spool files when it is complete and capture more information then just the status of the job.

Once the programs are ready for production, all you need to do is call the CL program. There are several ways to execute the CL program to periodically check the status of a subsystem(s). One way is to add it to your job scheduler to run at set times.

Below is a breakdown of this process.

  1. Create a physical file that is called SPOOLI with a single field 133 bytes called SPOOL.
  2. Create a CL program to get the status of all active jobs in a subsystem and create a spool file.
  3. Copy the spool file to file SPOOLI
  4. Call and RPG program to read the status of the job(s)
  5. Execute logic within the RPG program when a job is in MSGW

Here is the CL & RPG source to support the above process.

CL Program GETSTAT

PGM
WRKACTJOB  OUTPUT(*PRINT) SBS(QBATCH)            
CPYSPLF    FILE(QPDSPAJB) TOFILE(*LIBL/SPOOLI) + 
             SPLNBR(*LAST)                       
CALL       PGM(CHKSTAT)
ENDPGM                             

RPG Program CHKSTAT

FSPOOLI    IF   E             DISK                                      
F                                     RENAME(SPOOL:SPOOLR)              
D*----------------------------------------------------------------      
D                 DS                                                    
D  SPOOL                  1    133                                      
D  @STAT                111    114                                      
C*----------------------------------------------------------------      
C     *INLR         DOUEQ     *ON                                       
C                   READ      SPOOLR                                 LR 
C     *INLR         IFEQ      *OFF                                      
C     @STAT         ANDEQ     'MSGW'                                    
C* Take action                                                          
C                   ENDIF                                               
C                   ENDDO                                               

-----------------------------------------
About the author: John Kohan is a senior programmer analyst at CT Codeworks.

==================================
MORE INFORMATION
==================================

  • Receive "MSGW" note by e-mail/phone
    With one main CL as control batch, the system can send e-mail when a MSGW in WRKACTJOB occurs. This also works with a message on cell phones that have message access.
  • Resequencing columns on the WRKACTJOB screen
    If you've ever had a hard time finding the job referred to by error messages popping up in your QSYSOPR message queue, Search400.com member Dave Jeffries has a tip that will reduce your search time.
  • Three fun things you can do with WRKACTJOB
    Sometimes it's the simple tools -- like OS/400's green-screen Work with Active Jobs (WRKACTJOB) -- that you take for granted. WRKACTJOB's a lot older than many readers on this list and -- because of that longevity -- it contains some useful features that can be handy in different situations.
  • Proper way to end WRKACTJOB
    Most iSeries (AS/400) users do not use the correct procedure to end the WRKACTJOB command. The common method used involves the user pressing the "F3" or the "F12" command keys. This is incorrect.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Application Development
iSeries calling an .exe
Top 10 programmer tips
Formatted work job scheduler
Convert system date and time
Mixing free format code with embedded SQL
SQL update a field in one file from a field in another file
Webcasts for iSeries programmers
Programming advice from the pros
Easy code copying via the drag and drop method
Setting FTP time-outs

iSeries CL programming
Taking advantage of CL advancements, starting with V5R3
Checking in on your IBM i authorization lists
Running PHP open source applications: NOBODY needs authority
Simplify the process of converting a spool file from iSeries into an Excel spreadsheet
CL program for daily backups
An automated CL method of moving a query from AS/400 to Excel
Changing user password expiration
Eight steps for creating program documentation using AS/400 utilities
DAYSPAST CLLE program for AS/400: Compares object creation date with today's date
Advanced Job Scheduler help

Systems Management
Can you trust all those trigger programs?
Are your backups complete?
Controlling remote command processing
Watch your profiles
Avoid locking issues
Send message to users at a remote site
Security journal receiver management
Top 10 backup commands
Tracking critical file access in real time
Create an iSeries Access image and update it with the latest Service Pack

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

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.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts