How to Abort the job based on some logic?

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sasikiran
Participant
Posts: 17
Joined: Wed Dec 14, 2005 3:20 am
Location: Australia
Contact:

How to Abort the job based on some logic?

Post by sasikiran »

Hi All,

I have a senario,

- I have to check one folder for given file name(Ex:emp.txt), if file exists then ok else i want to abort the job.

- I am using folder stage to verify whether files is exists or not

- I don't know how to abort the job if file is not found. :?


please help me out.

Thanks for reply

Sas
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Don't do it that way at all.

Use a Wait For File activity in a job sequence. You can have one output from this when the file exists (or comes into existence within the required time period) that then executes your job. You have another output that is taken when the timeout expires without the file appearing. This does not execute your job at all.

By this means there's no need to abort anything; you retain complete control. Please refer to my recent Best Practices post for more.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sasikiran
Participant
Posts: 17
Joined: Wed Dec 14, 2005 3:20 am
Location: Australia
Contact:

Post by sasikiran »

Hi Ray,

My Requirment is

- If file is found then I have to move further and populate staging table.

- If file is not found then I have abort the job and I have to send a mail saying that required file is not there.

how can i do that?.

Thnaks & Regards
Sas
saikir
Participant
Posts: 92
Joined: Wed Nov 08, 2006 12:25 am
Location: Minneapolis
Contact:

Post by saikir »

Hi,

I am not totally clear of your requirement. However, if you want abort a job you can use UtilityAbortToLog. You can find more information in the datastage documentation by searchin with the keyword Utility Transforms

Sai
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

sasikiran wrote:- If file is not found then I have abort the job and I have to send a mail saying that required file is not there.
Just run the job. If the file isn't there, the job will abort without you having to do anything. To send an email in that case, you'll need to use a Sequence job to run the job and trigger an email in the event of a failure.

If you want something more graceful, use a WaitForFile stage to check for the existence of the file first. Set the wait time to 0 to get an existence check. Then you can send a specific email when the file isn't found rather than assuming the abort is for that reason. File found, run the job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

chulett wrote: Just run the job. If the file isn't there, the job will abort without you having to do anything.
There you go, its as simple as that :lol:
Dont abort the job, end it gracefully as others have noted.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sasikiran
Participant
Posts: 17
Joined: Wed Dec 14, 2005 3:20 am
Location: Australia
Contact:

Post by sasikiran »

Hi Craig,

I think this is much better option, thanks for quick responce.

Thnaks & Regards
Sas
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What is this fascination that people have developed with having jobs abort? Never design to abort, say I.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Me thinks the same :wink:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Other than for Restartable Sequence jobs, I'm right there with ya. :wink:
-craig

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