Email and SMS Error Notifications from an AS/400
Posted on March 28th, 2008 | 6 Comments »
I wanted to be more proactive when a job on our System i crashed so I started looking into options to send an email notification and SMS text message if something needed attention. After searching for a bit I came across a program on code400.com that was very close to what I wanted. This is an RPGLE program that uses the QUSLJOB API to list any job that is in *MSGW status and then send an email with the details of the job’s error using SNDDST. I made a few modifications to the code after trying it to better fit my needs. The program only had the capability to send to one email address yet I wanted to send it to an email distribution list on our Exchange server as well as send a text message to my phone for after hours support. The program also sent EVERY job in *MSGW, including any printer alignment messages. With my very basic knowledge of RPG I was able to add multiple email address variables and exclude any job that runs in the QSPL subsystem from being included.
Once the program ran to my liking I wrote a simple CL program that would call the program every 5 min and added the CL as an auto start job entry to our ITDEPT subsystem. I’ve had this configuration running for the past 6 months and it’s a great way to stay on top of any jobs that may be holding up QBATCH. Critical system jobs are usually fixed before end users even know something was broken.
Download the code here. The two variables for email are ‘emailaddress’ and ‘emailaddress1′. Simply change the variables to the email addresses you would like the messages sent to and compile.

6 Responses
Hi Eric I am getting the following error when compiling your code,
Would you pliz help:
M e s s a g e S u m m a r y
Msg id Sv Number Message text
*RNF7031 00 89 The name or indicator is not referenced.
*RNF3315 20 1 The Name entry is already defined on a Definition
Specification; defaults to blanks.
*RNF0257 30 89 Form-Type entry for main procedure not valid or out of
sequence.
*RNF0274 30 2 Compiler directive not recognized; directive ignored.
*RNF7030 30 1 The name or indicator is not defined.
*…+….1….+….2….+….3….+….4….+….5….+….6….+….7….+….8….
*RNF7023 40 1 The Compiler cannot determine how the program can end.
Please email me at ericpell at gmail dot com and I’ll see if I can lend a hand.
Hi tell me is it possible to just copy and paste your code into a cl i create?
Your help will be much appreciated.
Well, it’s an RPGLE program. The easiest way to get it to run is to use the IBM Websphere Development Studio and create a new RPGLE object on your AS/400, then compile that.
hai eric, i cannot download your source code ???
file not found
Sorry about that, the link is fixed now. Please try again.