After job subroutine aborts

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

After job subroutine aborts

Post by devidotcom »

Hi All,

Following is the code to abort the job if the link count of a reject link is greater that zero.

$INCLUDE DSINCLUDE JOBCONTROL.H

hJob = DSAttachJob("EDQS_CIS_SEGMENTATION", DSJ.ERRFATAL)


If NOT(hJob) Then
Call DSLogFatal("Job Attach Failed", "JobControl")
Abort
End

RowCount = DSGetLinkInfo(hJob,"Lkp_For_IDs","Lnk_Cpy_Reject", DSJ.LINKROWCOUNT)

if RowCount=0 then
call DSLogInfo("Lookup with EDQS_CALENDAR or EDQS_BATCH_DIM passed", "rt_segment_lkp")
end
Else
call DSLogFatal("Lookup with EDQS_CALENDAR or EDQS_BATCH_DIM failed","rt_segment_lkp")
Abort
end

Deterr = DSDetachJob (hJob)
ErrorCode = 0 ;* set this to non-zero to stop the stage/job

The job runs successfully but waits for a long time to run the after job subrountine and gives the following error.

EDQS_CIS_SEGMENTATION..AfterJob (fatal error from DSAttachJob): Job control fatal error (0)
(DSCloseJob) Cannot refer to own job handle

Any inputs..
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

Closing this post. The problem got resolved.
As I am calling the after job subroutine from the same job we need to use DSJ.ME.

Please find the modified code.

$INCLUDE DSINCLUDE JOBCONTROL.H


RowCount = DSGetLinkInfo(DSJ.ME,"Lkp_For_IDs","Lnk_Cpy_Reject", DSJ.LINKROWCOUNT)

if RowCount=0 then
call DSLogInfo("Lookup with EDQS_CALENDAR or EDQS_BATCH_DIM passed", "rt_segment_lkp")
end
Else
call DSLogFatal("Lookup with EDQS_CALENDAR or EDQS_BATCH_DIM failed","rt_segment_lkp")
Abort
end

ErrorCode = 0 ;* set this to non-zero to stop the stage/job

Thanks
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Trying to abort the same job using its after job subroutine.

Use the "Abort After Rows" option in the Transformer for reject link. A routine is not really required.
Following is the code to abort the job if the link count of a reject link is greater that zero.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

Thanks Josh.
But this reject link is from the lookup stage. Is it possible even in a lookup stage to abort after certain number of rows.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Specify the 'Condition' in Lookup stage to fail.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

How do I do it.
What would the condition be? If I do not obtain any value from the reference link I need to abort the job.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just set the "Lookup Failed" rule to "Fail", which is its default value.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
devidotcom
Participant
Posts: 247
Joined: Thu Apr 27, 2006 6:38 am
Location: Hyderabad

Post by devidotcom »

I tried that. If I have 8 rows from the reference link out of which one is the right one then the lookup shows failed on the remaining reference records. Also this would not display the error message correctly why the lookup failed.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Can you give an example with values? If even only one row is returned from the lookup reference link, then the lookup is considered to have succeeded.
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