Job Control Error
Moderators: chulett, rschirm, roy
Job Control Error
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 ?
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
MB
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!
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
MB
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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
MB
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 37
- Joined: Mon Dec 08, 2008 4:02 am
- Location: Milton Keynes, UK
Just as an aside, don't use the ABORT statement in job control. Use:
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:
Code: Select all
Call DSLogFatal("Some meaningful reason for stopping", "Some context")
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.If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: M_Ashish_Job_3", "JobControl")
Abort
End
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 37
- Joined: Mon Dec 08, 2008 4:02 am
- Location: Milton Keynes, UK
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.
Thanks Len ! It worked. Not just job working perfectly , it recovered from falling into indefinite hold also which was happening earlier.LenGreenwood wrote:Just as an aside, don't use the ABORT statement in job control. Use:
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:Code: Select all
Call DSLogFatal("Some meaningful reason for stopping", "Some context")
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.If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: M_Ashish_Job_3", "JobControl")
Abort
End
Rgds,
MB
MB