sending reject file if records are rejected.

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
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

sending reject file if records are rejected.

Post by marpadga18 »

Hi I need some inputs.
My requirement:
I have 3 requirements which are running fine.
1st UNIX script- Running as expected
2nd job loads the data into sql server table- Running as expected (with reject logic in transformer stage)
3rd job load the status of the job in audit table which is in oracle db- Running as expected
Now I need to send a mail if it rejects any records to the reject file.
Now can any one share their ideas? In the main sequence how to implement this logic.
Thanks,
M
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In the Sequence use something (routine, script) to check the size of the reject file and conditionally send the email if the file isn't 'empty'. There are 'test' conditions you can use or perhaps 'wc -l' to do the actual check.
-craig

"You can never have too many knives" -- Logan Nine Fingers
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

Post by marpadga18 »

Reject file size is >0

in execute command i am giveing the path of the reject file were it is existing and then the command wc -w Reject_UK_VAT.txt and
trigger as
Convert(@FM,"", Execute_Command_42.$CommandOutput) > 0
it is no giving me exact results?
please correct me if I am wrong?
Thanks,
M
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Depends how you want to handle it - One way is to have a copy stage after the reject link - one output goes to a file, the other can go to an external target stage that calls an unix mailer ( mailx) - you can tweak this output so that you can summarize the reject statistics in aggregator/transformer stages and pass this as an ouput to the cat command, which can be piped to mailx
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to put the command first and then give it the full filename to check, that or cd to the directory then do the check.
-craig

"You can never have too many knives" -- Logan Nine Fingers
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

Post by marpadga18 »

wc -m Reject_UK_VAT.txt i am executing from putty it is returning value 8 as file size which is correct but how to implement in datastage execute command?
what should i give in trigger to send mail if file size is >0?
Thanks,
M
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to recognize the difference between the 'current working directory' in putty versus what it is in DataStage. What I posted previous tells you how to handle that difference.

Your trigger is fine.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... in case it's still unclear what needs doing here... your final UNIX command that gets run after the two "halves" in the stage are put together need to look like one of these two:

Code: Select all

cd \The\Director\Where\TheFile\Lives && wc -m Reject_UK_VAT.txt

-or-

wc -m \The\Director\Where\TheFile\Lives\Reject_UK_VAT.txt
-craig

"You can never have too many knives" -- Logan Nine Fingers
marpadga18
Premium Member
Premium Member
Posts: 96
Joined: Fri Aug 20, 2010 8:51 am

Post by marpadga18 »

chulett wrote:So... in case it's still unclear what needs doing here... your final UNIX command that gets run after the two "halves" in the stage are put together need to look like one of these two:

Code: Select all

cd \The\Director\Where\TheFile\Lives && wc -m Reject_UK_VAT.txt

-or-

wc -m \The\Director\Where\TheFile\Lives\Reject_UK_VAT.txt
I wrote unix script which returns a integer value '1'if the file size is >0.
then in execute command for trigger
Convert(@FM,"", shellscriptwhichcheckthefile size.$CommandOutput) > 1
it is working fine it is sending reject file in email as expected.

any way thanks for u r quick inputs :):)
Thanks,
M
tminelgin
Premium Member
Premium Member
Posts: 13
Joined: Tue Oct 19, 2010 12:09 pm

If running via shell script;

Post by tminelgin »

File_len =`cat path/path/file.txt | wc -l'
if file_len > 0
then
mailx command with parms.

Be careful those are tics not apostrophes!
You set sender and recipients to parms.
The sequencer also has a mail stage that can be conditionally called.
swapnilverma
Participant
Posts: 135
Joined: Tue Aug 14, 2007 4:27 am
Location: Mumbai

Post by swapnilverma »

if -z reject_file

then

mailx with parameter -s " We have rejects "

else

mailx with parm -s " NO rejects "
Thanks
Swapnil

"Whenever you find whole world against you just turn around and Lead the world"
Post Reply