How to capture error message of a job and send it in mail

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
mourya33
Participant
Posts: 8
Joined: Fri Mar 20, 2009 3:53 am

How to capture error message of a job and send it in mail

Post by mourya33 »

We have a requirement to capture the error message of an aborted job and send the message by email. We need to capture the exact error message that is displayed in the director log. Please provide any inputs on this.


Thanks in advance
Mourya
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

I have a similar issue. I need to capture the job status and in case of failure, I need to send out an email notification. To do this I created a server routine that is coded as follows:

Deffun DSRMessage(A1) Calling "*DataStage*DSR_MESSAGE"
Equate RoutineName To "SendMessageOnFailure"

$INCLUDE DSINCLUDE JOBCONTROL.H

ErrorCode=0

JobNm=DSGetJobInfo(JobName,DSJ.JOBNAME)
JobStat=DSGetJobInfo(JobName,DSJ.JOBINTERIMSTATUS)
Call DSLogInfo("Job ":JobNm:" Status:":JobStat, RoutineName)


If JobStat<>1
Then the sequence job faile
Ans = DSSendMail("From:aaa@xxx.com\nTo:bbb@xxx.com\nSubject:Job Failure\nBody:Failed to load successfully\n")
End

I set up a sequence job to call this routine. However the sequence job fails. I am not sure if this is the right approach, but perhaps someone else has some ideas?
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

I apologize. I made a slight mistake in the code. Here it is:
Deffun DSRMessage(A1) Calling "*DataStage*DSR_MESSAGE"
Equate RoutineName To "SendMessageOnFailure"

$INCLUDE DSINCLUDE JOBCONTROL.H

ErrorCode=0

JobNm=DSGetJobInfo(JobName,DSJ.JOBNAME)
JobStat=DSGetJobInfo(JobName,DSJ.JOBINTERIMSTATUS)
Call DSLogInfo("Job ":JobNm:" Status:":JobStat, RoutineName)


If JobStat<>1
Ans = DSSendMail("From:aaa@xxx.com\nTo:bbb@xxx.com\nSubject:Job Failure\nBody:Failed to load successfully\n")
End
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Did the above code will give the actual error message that we will get in director ?
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

Here's the error I got from the log of the sequence job:
SendMessageOnHourlyAbort..JobControl (@Routine_Activity_0): Controller problem: BASIC routine is not cataloged: DSU.SendMessageOnAbort
aluthra48
Participant
Posts: 66
Joined: Thu Mar 05, 2009 9:59 am

Post by aluthra48 »

One more note...I tested the routine independently of the sequence job, and it works fine. The problems seems to be with the sequence job that executes the routine
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The Notification Activity stage will include that information when you check the 'Include Job Status in email' option.
-craig

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