Email Notification

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
cp2098
Premium Member
Premium Member
Posts: 8
Joined: Tue Nov 16, 2010 10:57 am

Email Notification

Post 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!
rajeevm
Participant
Posts: 135
Joined: Sun Jan 22, 2006 10:44 am

Post 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.
cp2098
Premium Member
Premium Member
Posts: 8
Joined: Tue Nov 16, 2010 10:57 am

Post 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.
koolsun85
Participant
Posts: 36
Joined: Tue Jun 15, 2010 3:30 pm
Location: Tampa

Post by koolsun85 »

Use After Job Subroutine DSSendMail to send an email and attach the rejected file in the job itself.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
cp2098
Premium Member
Premium Member
Posts: 8
Joined: Tue Nov 16, 2010 10:57 am

Post 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.
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Craig's suggestion avoids that situation by checking to see if records were rejected.
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rsunny
Participant
Posts: 223
Joined: Sat Jul 03, 2010 10:22 pm

Post by rsunny »

Hi craig,

Can't we do it through parallel job?
cp2098
Premium Member
Premium Member
Posts: 8
Joined: Tue Nov 16, 2010 10:57 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

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