Mail Notification

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
shiva459
Premium Member
Premium Member
Posts: 100
Joined: Wed Jun 11, 2003 1:49 am
Location: Bangalore

Mail Notification

Post by shiva459 »

Hi ,

I am trying to implement mail notification from a batch.I want to send an email if any job in the batch fails which will include the reason for failure.I know to implement it via graphical sequencer but not sure how to include in a batch code.
I am attaching the batch code below, please guide me how to call the DSSendMail routine in case of failure at the end of every job.
RunJobs:
* Setup XYZ, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("XYZ", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: XYZ", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "Arg1", Arg1)
ErrCode = DSSetParam(hJob1, "Arg2", Arg2)

ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: XYZ", "JobControl")
End


Thanks
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Shiva459,

on page 6-188 of the BASIC Guide you will find the exact description on how to do this; as this is very straightforward programming I am not sure where your problem is.

You need only add:

Code: Select all

   ParameterString = "From:Pseudo@Nominus.Com\nTo:Shiva459@SFBay.Org\nSubject:DSSendMail Function Call\nBody:\n"
 ReturnCode = DSSendMail(ParameterString)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If that's not enough, look at the Routine called DSSendMailTester (in the Built-In\Utilities category) for a coded example.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And make sure you do it before calling DSLogFatal. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply