Batch is running !
Moderators: chulett, rschirm, roy
Batch is running !
Please Help,
I am running a server job control, which executes a routine. Status of the batch still shows "running" even the routine's task completed successfully.
CONTROLLER CODE:
*$INCLUDE DSINCLUDE DSR_UVCONST.H
*$INCLUDE DSINCLUDE DSR_COMCONST.H
Arg1 = 0
Code1 = 0
Status = 0
Code = 0
DEFFUN CompileJobRoutine(Arg1,Arg2) Calling "DSU.CompileJobRoutine"
*DEFFUN TestRoutine(Arg1,Arg2) Calling "DSU.TestRoutine"
RunHandle = DSAttachJob("KeyHashBookClose", DSJ.ERRNONE)
Status = DSGetJobInfo(RunHandle, DSJ.JOBSTATUS)
Result = DSGetJobInfo(RunHandle,DSJ.JOBSTARTTIMESTAMP)
ResultDate = SUBSTRINGS(Result,1,10)
CurrentDate = Oconv(DATE(),"D4-YMD")
If Status = DSJS.RUNOK or '99' and ResultDate LT CurrentDate Then
Code = DSPrepareJob(RunHandle)
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
If Status = DSJS.RUNFAILED and ResultDate LE CurrentDate Then
Arg2 = "KeyHashBookClose"
Result = CompileJobRoutine(Ans,Arg2); * compile job
Result = OCONV(Result, "MCN")
If Result >= 1 Then
Code = DSPrepareJob(RunHandle)
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
End
Goto Fini
Fini:
ROUTINE CODE:
$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H
Code = Arg1
MyJobNo = Arg2
SUBR = DSR.SUB.JOB
Dummy2 = ""
Key = DSR.SUB.JOB.COMPILE
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
Ignore = 0
JobNo = DSRGetJob(Arg2,Ignore)
Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo
Ans = 1
Key = DSR.SUB.JOB.RELEASE ; * unlock job, ignoring any errors
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
Return(Ans)
I am running a server job control, which executes a routine. Status of the batch still shows "running" even the routine's task completed successfully.
CONTROLLER CODE:
*$INCLUDE DSINCLUDE DSR_UVCONST.H
*$INCLUDE DSINCLUDE DSR_COMCONST.H
Arg1 = 0
Code1 = 0
Status = 0
Code = 0
DEFFUN CompileJobRoutine(Arg1,Arg2) Calling "DSU.CompileJobRoutine"
*DEFFUN TestRoutine(Arg1,Arg2) Calling "DSU.TestRoutine"
RunHandle = DSAttachJob("KeyHashBookClose", DSJ.ERRNONE)
Status = DSGetJobInfo(RunHandle, DSJ.JOBSTATUS)
Result = DSGetJobInfo(RunHandle,DSJ.JOBSTARTTIMESTAMP)
ResultDate = SUBSTRINGS(Result,1,10)
CurrentDate = Oconv(DATE(),"D4-YMD")
If Status = DSJS.RUNOK or '99' and ResultDate LT CurrentDate Then
Code = DSPrepareJob(RunHandle)
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
If Status = DSJS.RUNFAILED and ResultDate LE CurrentDate Then
Arg2 = "KeyHashBookClose"
Result = CompileJobRoutine(Ans,Arg2); * compile job
Result = OCONV(Result, "MCN")
If Result >= 1 Then
Code = DSPrepareJob(RunHandle)
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
End
Goto Fini
Fini:
ROUTINE CODE:
$INCLUDE DSINCLUDE JOBCONTROL.H
$INCLUDE DSINCLUDE DSR_UVCONST.H
$INCLUDE DSINCLUDE DSR_COMCONST.H
Code = Arg1
MyJobNo = Arg2
SUBR = DSR.SUB.JOB
Dummy2 = ""
Key = DSR.SUB.JOB.COMPILE
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
Ignore = 0
JobNo = DSRGetJob(Arg2,Ignore)
Execute "CLEAR.FILE ":DSR.RTSTATUS.FNAME:JobNo
Execute "CLEAR.FILE ":DSR.RTLOG.FNAME:JobNo
Ans = 1
Key = DSR.SUB.JOB.RELEASE ; * unlock job, ignoring any errors
Call @SUBR(Key, Arg2)
Call DSD.Init(MyJobNo, Dummy2)
Return(Ans)
Simba
If you try to compile the current job or a job running then it does unpredictable things. Compiling the job that is running is very difficult to fix. You need to reset status and maybe pull it up in the Designer and recompile.
I would clear files after you release the job. Also there is no wait for job routine.
Kim.
If you try to compile the current job or a job running then it does unpredictable things. Compiling the job that is running is very difficult to fix. You need to reset status and maybe pull it up in the Designer and recompile.
I would clear files after you release the job. Also there is no wait for job routine.
Kim.
Mamu Kim
Kim,kduke wrote:Simba
If you try to compile the current job or a job running then it does unpredictable things. Compiling the job that is running is very difficult to fix. You need to reset status and maybe pull it up in the Designer and recompile.
I would clear files after you release the job. Also there is no wait for job routine.
Kim.
Thanks for you reply,. I have executed a batch, which is supposed to compile a job. Based on the return code i am running the compiled in this batch. My batch in showing "running". The job i am running from this batch has been finished. By the way, please help me to use DSWaitfor.
Thanks,
This statement is wrong:
It should be something like:
Code: Select all
If Status = DSJS.RUNOK or '99' and ResultDate LT CurrentDate Then
Code: Select all
If ( Status = DSJS.RUNOK or Status = '99' ) and ResultDate LT CurrentDate Then
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Thanks Ken,kcbland wrote:This statement is wrong:
It should be something like:Code: Select all
If Status = DSJS.RUNOK or '99' and ResultDate LT CurrentDate Then
Code: Select all
If ( Status = DSJS.RUNOK or Status = '99' ) and ResultDate LT CurrentDate Then
I have modified the code, Can you tell how DSLogToController() works.
I have used this function for "silent exit". Now with the following code batch is showing "finished".
If Status = (DSJS.RUNOK or '99') and ResultDate LT CurrentDate Then
Code = DSPrepareJob(RunHandle)
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
**************** batch is "running" with this code************
If Status = DSJS.RUNFAILED and ResultDate LE CurrentDate Then
Result = CompileJobRoutine(Arg1,Arg2); * compile job
Result = OCONV(Result, "MCN")
If Result >= 1 Then
*Call DSLogToController("") **Not sure to include
Code = DSRunJob(RunHandle,DSJ.RUNNORMAL)
End
End
****************************************************
Your logic is still wrong! You have:
and it should be:
Code: Select all
If Status = (DSJS.RUNOK or '99')
Code: Select all
If (Status = DSJS.RUNOK or Status = '99')
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSLogToController() puts messages into the job log of the parent job that started the current job.
Example:
Batch Job A starts Batch Job B. Batch Job B does a DSLogToController() call and messages appear in the log of Batch Job A.
Example:
Batch Job A starts Batch Job B. Batch Job B does a DSLogToController() call and messages appear in the log of Batch Job A.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
San
If you build a batch job then there is a drop down list of job names. Next to it is an add job button. This is the code it generates.
The DSWaitForJob() takes the hJob1 job handle from the return DSAttachJob() routine and waits for it to finish before the next line of code is executed. Otherwise the job continues running in the background.
This maybe important to what you are trying to do. I am still not sure why you are compiling jobs this why. Wouldn't be easier to just reset a job? If all you need is to get a job in a runable state then reset is better. Unless you have some program which changes the job then do not compile it.
Code: Select all
* Setup AdjustmentCode, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("AdjustmentCode", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: AdjustmentCode", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob1, "matrixsrc_dsn", "PROD")
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: AdjustmentCode", "JobControl")
End
Code: Select all
ErrCode = DSWaitForJob(hJob1)
This maybe important to what you are trying to do. I am still not sure why you are compiling jobs this why. Wouldn't be easier to just reset a job? If all you need is to get a job in a runable state then reset is better. Unless you have some program which changes the job then do not compile it.
Mamu Kim
Thank you. Our goal is to run a sequence of jobs, if any of the job gets aborted then the seq should start from the aborted job. The approch is to compile and run the jobs if they are aborted. If jobs are aborted in the production. The plan is to fix them in the development and just import to production,. The status is still abort. That is why we are trying to compile and run.kduke wrote:San
If you build a batch job then there is a drop down list of job names. Next to it is an add job button. This is the code it generates.Code: Select all
* Setup AdjustmentCode, run it, wait for it to finish, and test for success hJob1 = DSAttachJob("AdjustmentCode", DSJ.ERRFATAL) If NOT(hJob1) Then Call DSLogFatal("Job Attach Failed: AdjustmentCode", "JobControl") Abort End ErrCode = DSSetParam(hJob1, "matrixsrc_dsn", "PROD") 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: AdjustmentCode", "JobControl") End
The DSWaitForJob() takes the hJob1 job handle from the return DSAttachJob() routine and waits for it to finish before the next line of code is executed. Otherwise the job continues running in the background.Code: Select all
ErrCode = DSWaitForJob(hJob1)
This maybe important to what you are trying to do. I am still not sure why you are compiling jobs this why. Wouldn't be easier to just reset a job? If all you need is to get a job in a runable state then reset is better. Unless you have some program which changes the job then do not compile it.
Yeah mate, like Kim says you should really reset the job. Compiling jobs to get them back to a runnable state means that those jobs are editable (as far as I am aware). However, they should really be read-only on your production instance.Simba wrote: Thank you. Our goal is to run a sequence of jobs, if any of the job gets aborted then the seq should start from the aborted job. The approch is to compile and run the jobs if they are aborted. If jobs are aborted in the production. The plan is to fix them in the development and just import to production,. The status is still abort. That is why we are trying to compile and run.
like a tiger
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
1. Attach job (DSAttachJob)
2. Check that attach succeeded (DSGetJobInfo(hJob, DSJ.JOBNAME))
3. Check job status (DSGetJobInfo(hJob, DSJ.JOBSTATUS))
4. If job status indicates that job is worth attempting to reset:
(a) detach job (DSDetachJob)
(b) attach job (DSAttachJob) -- probably OK not to verify again
(c) run job in reset mode (DSRunJob(hJob, DSJ.RUNRESET))
(d) wait for this to finish (DSWaitForJob)
(e) check new exit status (DSGetJobInfo)
(f) detach job
(g) attach job
5. Check job status (see 3.)
6. If job is in a runnable state:
(a) set each parameter value
(b) verify that parameter value was correctly set
(c) run the job in normal mode (DSRunJob(hJob, DSJ.RUNNORMAL))
(d) wait for job to finish -- your code
(e) interrogate job for any required information
7. Detach job.
2. Check that attach succeeded (DSGetJobInfo(hJob, DSJ.JOBNAME))
3. Check job status (DSGetJobInfo(hJob, DSJ.JOBSTATUS))
4. If job status indicates that job is worth attempting to reset:
(a) detach job (DSDetachJob)
(b) attach job (DSAttachJob) -- probably OK not to verify again
(c) run job in reset mode (DSRunJob(hJob, DSJ.RUNRESET))
(d) wait for this to finish (DSWaitForJob)
(e) check new exit status (DSGetJobInfo)
(f) detach job
(g) attach job
5. Check job status (see 3.)
6. If job is in a runnable state:
(a) set each parameter value
(b) verify that parameter value was correctly set
(c) run the job in normal mode (DSRunJob(hJob, DSJ.RUNNORMAL))
(d) wait for job to finish -- your code
(e) interrogate job for any required information
7. Detach job.
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.