Pass value between jobs

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
sim
Participant
Posts: 13
Joined: Wed Feb 18, 2004 6:20 pm

Pass value between jobs

Post by sim »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

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
sim
Participant
Posts: 13
Joined: Wed Feb 18, 2004 6:20 pm

Post by sim »

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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sim
Participant
Posts: 13
Joined: Wed Feb 18, 2004 6:20 pm

Post by sim »

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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

sim wrote:Is there any command like 'printout', or 'cout (C++'s)' to print output to logfile? Help me...I am lost.
DSLogInfo
DSLogWarn
DSLogFatal

Check the online help. You want the first one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
Post Reply