Job Control Error

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
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Job Control Error

Post by mdbatra »

Hi ,

I am running a job control as follows(for reading job names from a file & get the corresponding information in variables)

OPENSEQ 'C:\Project_Files\JobName.txt' TO OUTPUT ELSE ABORT

for i=1 to 18

READSEQ A FROM OUTPUT ELSE ABORT

inivar=DSAttachJob(A,DSJ.ERRWARN)
midvar=DSGetJobInfo(inivar,DSJ.JOBNAME)
finvar=DSGetJobInfo(inivar,DSJ.STAGELIST)



* Setup M_Ashish_Job_3, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("M_Ashish_Job_3", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: M_Ashish_Job_3", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "Job_Name",midvar)
ErrCode = DSSetParam(hJob1, "Stg_name",finvar)
ErrCode = DSSetDisableProjectHandler(hJob1, @FALSE)
ErrCode = DSSetDisableJobHandler(hJob1, @FALSE)
ErrCode = DSRunJob(hJob1, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob1)
Status = DSGetJobInfo(hJob1, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: M_Ashish_Job_3", "JobControl")
End

NEXT i

CLOSESEQ OUTPUT

When i run this, the control goes on indefinite hold. So,
1) What can be the cause ? Any syntax problem or some additional thing to do?
2) How to stop a job which went on indefinite hold ?
Rgds,
MB
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

i have searched the forum for ReadSeq & tried umptine times but still problem persists.

May i know the syntax for simply reading a single column of a file & file which has just 1 column , sequetially & then passing the column name to the variables.
Just want to cross-check what i have given above is fine or not!
Rgds,
MB
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Try logging messages to see where it goes into abyss
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try detaching hJob1 when you're done with that job, so that you don't get a job locked situation.

Why are you executing the same job 18 times?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

ray.wurlod wrote:Try detaching hJob1 when you're done with that job, so that you don't get a job locked situation.

Why are you executing the same job 18 times? ...

The file i am reading has 18 enteries.
While initially learning for reading a file sequentially, i saw that i need to loop it for the number of enteries to be read.
I fear if this is the problem :(

If yes, please provide assistance !
Rgds,
MB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Write out IN ENGLISH what you want to do.

It is not clear from your code (a) because it is not indented (use Code tags) and (b) because you don't appear to have any clear idea of precisely what you want to accomplish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

I have names of all the jobs in a file. In a job control, i need to read the name of the job from file, evaluate some information using DS functions & pass them to the parameters defined for the 'Controlled Job' .
& this needs to be repeated for all the jobs.
Rgds,
MB
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If I were the programmer I would not be at all happy with a specification like "extract some information". What I'm trying to get you to do is to create a proper technical specification against which cogent advice as to coding may be given.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
LenGreenwood
Premium Member
Premium Member
Posts: 37
Joined: Mon Dec 08, 2008 4:02 am
Location: Milton Keynes, UK

Post by LenGreenwood »

Just as an aside, don't use the ABORT statement in job control. Use:

Code: Select all

Call DSLogFatal("Some meaningful reason for stopping", "Some context")
instead. That way the controlling job will stop gracefully, and log a message saying why it stopped. A Call to DSLogFatal never returns. So in the lines in your example that have:
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: M_Ashish_Job_3", "JobControl")
Abort
End
That particular Abort will never be executed. But the ABORTs higher up may well be, if the file does not exist or has more than 18 lines, for example.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Len, that's the code generated by DataStage. Try it some time - create a job control routine "the old way". I agree with you, even so. Indeed, what ever happened to "you must treat the handle variable as opaque"?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
LenGreenwood
Premium Member
Premium Member
Posts: 37
Joined: Mon Dec 08, 2008 4:02 am
Location: Milton Keynes, UK

Post by LenGreenwood »

Agreed that's generated code, and it should never have inserted that Abort, because it makes it look as if that's the way the job gets stopped. Don't know why it got left in - the subsequent (also generated) call to DSLogFatal in the first post makes it clearer. Still need to emphasize that one should not call naked Aborts within job control.
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

LenGreenwood wrote:Just as an aside, don't use the ABORT statement in job control. Use:

Code: Select all

Call DSLogFatal("Some meaningful reason for stopping", "Some context")
instead. That way the controlling job will stop gracefully, and log a message saying why it stopped. A Call to DSLogFatal never returns. So in the lines in your example that have:
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: M_Ashish_Job_3", "JobControl")
Abort
End
That particular Abort will never be executed. But the ABORTs higher up may well be, if the file does not exist or has more than 18 lines, for example.
Thanks Len ! It worked. Not just job working perfectly , it recovered from falling into indefinite hold also which was happening earlier.
Rgds,
MB
Post Reply