Notification - When job Unsuccessful

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
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Notification - When job Unsuccessful

Post by Titto »

Hi,

I want to send a mail using DSSendmail after job routine when ever job "Un-successfull". There is option to select run only when job is successful.
1) what if i don't check the box, will it send mail when job fails?
2) any other routine will help me out to send notification when the particular job fails .. any help!!

Thanks in advance
T
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

I tried writing a routine but it is not working.. here is the code.. anything wrong.. It is sending the mail if the Job aborts .
Error message :- After-job routine returned error: Error variable unassigned on return from AFTER routine DSU.UnSuccessSendMail

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H


JobHandle  = DSJ.ME
JobName    = DSGetJobInfo(JobHandle,DSJ.JOBNAME)
JobInvId   = DSJobInvocationId
if JobInvId ne "" then
   JobName:= ".":JobInvId
end

Status    = DSGetJobInfo(JobName,DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED or Status = DSJS.RUNWARN Then
 
 Reply = DSSendMail(InputArg)

   Begin Case
   Case Reply = DSJE.NOERROR
      ErrorCode = 0      ;* set to 0 - file checked OK, job continues
   Case @True
      ErrorCode = 1      ;* some other error, such as bad InputArg, stops the job if this is an after routine
   End Case
End
ameyvaidya
Charter Member
Charter Member
Posts: 166
Joined: Wed Mar 16, 2005 6:52 am
Location: Mumbai, India

Post by ameyvaidya »

Hi Titto,

The simplest solution would be to wrap a Job Sequence around your existing Job. The sequence can do the following:

1. Job Activity Executes the Job. Output trigger is unconditional to second stage
2. Second stage is a nested condition stage with one output trigger with the following condition "Job_Activity_1.$JobStatus <> DSJS.RUNOK"
3. Third activity is the notification activity to send email.


Hope this Helps.

Amey Vaidya
Post Reply