Page 1 of 1

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

Posted: Fri Mar 20, 2009 4:46 am
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

Posted: Fri Mar 20, 2009 11:19 am
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?

Posted: Fri Mar 20, 2009 11:20 am
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

Posted: Fri Mar 20, 2009 11:59 am
by vinothkumar
Did the above code will give the actual error message that we will get in director ?

Posted: Fri Mar 20, 2009 1:06 pm
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

Posted: Fri Mar 20, 2009 1:25 pm
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

Posted: Fri Mar 20, 2009 3:17 pm
by chulett
The Notification Activity stage will include that information when you check the 'Include Job Status in email' option.