How to abort a job in Afterjob sub routine

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

nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

How to abort a job in Afterjob sub routine

Post by nvuradi »

Hi All i have a requirement in which i have to abort the job
if the reject link count is greater than 0 i.e i have to abort the job if the job has some reject records.

this i have to take care in the after job sub routine ....for this i am using DSStopJob as..

if intNoRecRejected > 0 Then

iErrorCode=DSStopJob(DSJ.ME)
Call DSLogInfo("Stop error Code ":iErrorCode,DSJ.ME)

END

but it is returning the error code as -1.

is there any other way to abort the job for the above mentioned condition?

thanks,
Naru
sud
Premium Member
Premium Member
Posts: 366
Joined: Fri Dec 02, 2005 5:00 am
Location: Here I Am

Re: How to abort a job in Afterjob sub routine

Post by sud »

nvuradi wrote:...

is there any other way to abort the job for the above mentioned condition?
The question is where are you catching the rejections ? If from a transformer, the transformer has this option in the 'constraints'. Check it out.
It took me fifteen years to discover I had no talent for ETL, but I couldn't give it up because by that time I was too famous.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I'm not on a system where I have DS installed, but I seem to recall that DSStopJob() function can only be used from the controlling job. If you need to abort a job from the job itself you need to call DSLogFatal().
Better is to set the number of links output down a link to 0 so that the job aborts in the correct place and not after completing all processing.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Or Call 'Abort' in the routine. Or use 'Abort after n row' option for the reject link.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

Post by nvuradi »

kumar_s wrote:Or Call 'Abort' in the routine. Or use 'Abort after n row' option for the reject link. ...
hi i have to abort the job in Afterjob sub routine .....
can this be done??....

how can i use this ???..
Or use 'Abort after n row' option for the reject link. ...
nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

Post by nvuradi »

nvuradi wrote:
kumar_s wrote:Or Call 'Abort' in the routine. Or use 'Abort after n row' option for the reject link. ...
hi i have to abort the job in Afterjob sub routine .....
can this be done??....

how can i use this ???..
Or use 'Abort after n row' option for the reject link. ...
one more thing i dont have a transformer in my Job... :(
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you have no transform stage and don't want to put one in, then you should use the reject link as your abort trigger as mentioned twice above.
nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

Post by nvuradi »

ArndW wrote:If you have no transform stage and don't want to put one in, then you should use the reject link as your abort trigger as mentioned twice above. ...
using ErrorCode = 1 will work???
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

You have a reject link somewhere in your job as you specified in your original post. From which stage is this link coming from? Also, look at "Linking" in the DataStage Designer Guide starting at page 4-14.
nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

Post by nvuradi »

ArndW wrote:You have a reject link somewhere in your job as you specified in your original post. From which stage is this link coming from? Also, look at "Linking" in the DataStage Designer Guide starting at page 4-14.
this link is coming from an Oracle insert stage.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I see - I saw that this was posted in the Server forum and that changes things. Put your reject link to a transform stage, then onto to whatever file output stage (or a PEEK stage) you want. In the Transform output details tell the job to abort after 1 rows down that link.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

nvuradi wrote: one more thing i dont have a transformer in my Job... :(
Get one. Abort "after n rows" is a functionality present inside the px transformer.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

nvuradi wrote:i have to abort the job in Afterjob sub routine .....
can this be done??....

how can i use this ???..
1. Why? All rows that have been sent to the database have been committed by the time an after job subroutine is being executed. Aborting a job in an after job subroutine makes as much sense as buying a lottery ticket after the lottery has been drawn.

2. Yes it can be done. Make a call to DSLogFatal() within the after job subroutine.

3. Because of my point #1, this question is moot.
Last edited by ray.wurlod on Tue Feb 06, 2007 1:38 am, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
nvuradi
Participant
Posts: 54
Joined: Tue Dec 12, 2006 11:03 pm

Post by nvuradi »

ray.wurlod wrote:[quote="nvuradi]i have to abort the job in Afterjob sub routine .....
can this be done??....

how can i use this ???..
1. Why? All rows that have been sent to the database have been com ...[/quote]

i have to abort the job if table already has a record.......
still unable to solve it :oops:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your requirement to abort the job is unnecessary. A far better design would be to check that the row (or key value) in question does not already exit in the target table before attempting to insert it. Any row that does already exist can be captured in a different ("reject"?) stream and processed accordingly. There is still no need to abort the job. Maintain control at all time.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply