Page 1 of 1

Email Notification

Posted: Mon Feb 07, 2011 12:57 pm
by cp2098
Hi,
I'm a bit new to DataStage so please bear with me. I need to send an email notification when a lookup rejects a file. Does anyone know the easiest way to implement this?

Thanks!

Posted: Mon Feb 07, 2011 2:44 pm
by rajeevm
I think you can do it a job sequence . You can give the status of the job whether its failed or completed. You can even give the multiple recipients names seperated by a comma.

Posted: Mon Feb 07, 2011 3:06 pm
by cp2098
Since the job only "rejects" the rows that are not found in the lookup and the results are sent to a reject file via a reject link and the process continues then the status of the job is considered complete. What I want to do is to be able to send an email if there are rejects within that file. So the process should continue regardless of the rejects, I just want to notify someone that there were rejects and that they should have a look at those rejects.
rajeevm wrote:I think you can do it a job sequence . You can give the status of the job whether its failed or completed. You can even give the multiple recipients names seperated by a comma.

Posted: Mon Feb 07, 2011 3:37 pm
by koolsun85
Use After Job Subroutine DSSendMail to send an email and attach the rejected file in the job itself.

Posted: Mon Feb 07, 2011 7:07 pm
by chulett
Or build a Sequence job. A Routine Activity can check to see if anything was written down the reject link, or a Command Activity can check the size/row count of the file. If a non-zero value is found, the Notification Activity can be triggered to send an email and attach the file as well.

Posted: Tue Feb 08, 2011 7:46 am
by cp2098
Again bear with me because I'm a novice in DS.

My issue is that I only want to send the email when there are rejected records. A lookup always recreates the reject file regardless if there are any rejected records. With the approach you mention below, the email would be sent all the time regardless if I had any reject records?

koolsun85 wrote:Use After Job Subroutine DSSendMail to send an email and attach the rejected file in the job itself.

Posted: Tue Feb 08, 2011 8:03 am
by jwiles
Craig's suggestion avoids that situation by checking to see if records were rejected.

Posted: Tue Feb 08, 2011 8:22 am
by chulett
You could also write your own 'After Job' subroutine that did basically the same check I mentioned earlier and then conditionally called DSSendMail. If you do, make sure you Annotate that on the canvas and (perhaps) set the After Job area to run only if things are ending... gracefully.

Posted: Tue Feb 08, 2011 8:55 am
by rsunny
Find the number of rows that are going into the reject link and use DSSETUSERSTATUS of the row count and keep the job in sequence and trigger to send an email with the user status if it is greater than zero.

Posted: Tue Feb 08, 2011 8:58 am
by chulett
rsunny wrote:Find the number of rows that are going into the reject link and use DSSETUSERSTATUS of the row count and keep the job in sequence and trigger to send an email with the user status if it is greater than zero.
That's certainly another way - if we're talking about a Server job here.

Posted: Tue Feb 08, 2011 9:01 am
by rsunny
Hi craig,

Can't we do it through parallel job?

Posted: Tue Feb 08, 2011 11:43 am
by cp2098
Hi Craig: I really appreciate the advice you've given thus far.

Would you know the best place to research on Routine Activities? I've never used one so I don't know how to check the reject link.
chulett wrote:Or build a Sequence job. A Routine Activity can check to see if anything was written down the reject link, or a Command Activity can check the size/row count of the file. If a non-zero value is found, the Notification Activity can be triggered to send an email and attach the file as well.

Posted: Tue Feb 08, 2011 11:53 am
by chulett
Search here for examples of using the DSGetLinkInfo() function with the (off the top of my head) DSJ.LINKROWCOUNT InfoType. Build a generic routine that takes three arguments - job name, stage name and link name - then attach to the job, interrogate the link, set the return value to that count and then detach from the job. That would work for a Sequence job.

If you are going the After Job route, you can skip the job name and attach bits and use DSJ.ME as the handle. It means the executing job that called it.