Hi:
I have two jobs (Job1 and Job2). I want to pass a value from Job1 to Job2 using parameter. Job1 finds a max(column1) and this max value has to be passed to Job2's parameter. How do I do this? Thanks for your help.
Pass value between jobs
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Job0 is a controlling job (or job sequence) that runs Job1 then Job2. Job1 puts the value somewhere, perhaps its user status area, perhaps a text file. Job0 reads that value and uses it to set the parameter value for Job2 before running Job2.
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.
If the first job has only the responsibility of getting that max value and writing it somewhere, why not encapsulate that SQL logic into a shell script call or a DS routine wrapped to that shell script call? Then, you could fetch that value either in job control and pass it as a value, or, during a stage variable initialization perform that function call wrapped around the shell script executing a SQL script.
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 for your help. I'll try both of your approach (I have lot of time!). I tried Ray's way and I have job control code like this:[code]
MyVariable = 10
* Setup job1, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("job1", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: job1", "JobControl")
Abort
End
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: job1", "JobControl")
End
MyVariable = DSGetVarInfo(hJob1, "Transformer9", "maxvalue", DSJ.Varvalue)
* Setup job2, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("job2", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: job2", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob2, "MaximumVal", MyVariable)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: job2", "JobControl")
End
[/code]
job1 only is executed and job2 is never run. It just stops. I am new to Basic, so please correct me where I am doing mistake.
Thanks
MyVariable = 10
* Setup job1, run it, wait for it to finish, and test for success
hJob1 = DSAttachJob("job1", DSJ.ERRFATAL)
If NOT(hJob1) Then
Call DSLogFatal("Job Attach Failed: job1", "JobControl")
Abort
End
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: job1", "JobControl")
End
MyVariable = DSGetVarInfo(hJob1, "Transformer9", "maxvalue", DSJ.Varvalue)
* Setup job2, run it, wait for it to finish, and test for success
hJob2 = DSAttachJob("job2", DSJ.ERRFATAL)
If NOT(hJob2) Then
Call DSLogFatal("Job Attach Failed: job2", "JobControl")
Abort
End
ErrCode = DSSetParam(hJob2, "MaximumVal", MyVariable)
ErrCode = DSRunJob(hJob2, DSJ.RUNNORMAL)
ErrCode = DSWaitForJob(hJob2)
Status = DSGetJobInfo(hJob2, DSJ.JOBSTATUS)
If Status = DSJS.RUNFAILED Or Status = DSJS.CRASHED Then
* Fatal Error - No Return
Call DSLogFatal("Job Failed: job2", "JobControl")
End
[/code]
job1 only is executed and job2 is never run. It just stops. I am new to Basic, so please correct me where I am doing mistake.
Thanks
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The code looks OK. Put in some extra logging statements to diagnose what path is being taken through the code. In particular, determine why job2 isn't starting.
Are any abort messages (red icons) logged in any of the three jobs?
Are any abort messages (red icons) logged in any of the three jobs?
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.
There is no abort messages...job1 is finished with status OK. job2 is not executed at all and job0 'is running'. Even if I stop job0, it's not stopping. job0 is reset when I compile it again. How would I put logging statements to check errors? Is there any command like 'printout', or 'cout (C++'s)' to print output to logfile? Help me...I am lost.
Thanks
Thanks
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can also use DSLogEntry to put an entry into an attached job's log. In your case, you could log entries into Job1 and/or Job2 log from the code in Job0 using this function.
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.