Parameterize which Child Job to run

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
huckinj
Participant
Posts: 3
Joined: Fri Sep 10, 2004 9:39 am

Parameterize which Child Job to run

Post by huckinj »

Hello,

Please keep in mind that I am BRAND NEW to DataStage (I'm actually an intern). :)

I've got a parent job, which will then need to kick off one of a group of child jobs. I would like to hand the parent job a parameter containg the name of the child job that should run, and have only that child job run. Is there a way to do this?

Thanks very much.

-Jared
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

Hi Jared. Welcome.

Yes, you can do what you asked.

You do this in Job sequencer job.
1) Create a new Job Parameter JobToRun (or whatever you wish). Make it a List type and enter the job choices (e.g. Job1, Job2, Job3, etc).
2) Put a Nested Condition stage at the beginning of the job.
3) Add Job Activity stages for each of the jobs that you wish to run (the choices on the Job Parameter list you created in step 1).
4) Draw a link from the Nested Condition stage to each of the Job Activity stages. It would be helpful to you later, if you name these links the same as the jobs that they lead to.
5) Open the Nested Condition stage properties, and click on the Triggers tab.
6) On each link, make sure that the Expression Type is "Custom - (Conditional)". Under "Expression" you should see "<LHS> = <RHS>". Replace <LHS> with the Job Parameter name that you created. Replace <RHS> with the appropriate value (from the list of values that you created for this Job Parameter in step 1).

So, let me give you an example. You have jobs Job1, Job2 and Job3 that you want to choose from.
1) You create a Job Sequencer
2) Add a Nested Condition stage and three Job Activity stages.
3) You draw a link from the Nested Condition stage to each of the three Job Activity stages.
4) You set up each Job Activity stage to run one of your jobs.
5) Name the link to each Job Activity stage, the name of the job that is run from that Job Activity stage (Job1, Job2, or Job3).
6) Create a new Job Parameter called JobToRun. Set the type to List, and double-click in the Default Value cell to open the List Dialog. In the Value field, enter Job1 and Press the 'Add' button. Do the same for values Job2, and Job3, so that the List field in the middle of the dialog contains 'Job1', 'Job2', and 'Job3' (without the quotes). You can set one of these as the default, if you wish, by choosing the value you want for the default value from the Set Default drop down list. Click on the 'OK' button to close the List Dialog and save your settings.
7) Open the Nested Condition stage properties (double-click on the nested condition stage). You should see links named Job1, Job2, and Job3. Make sure that the 'Expression Type' for each link is 'Custom - (Conditional)'. Note that the 'Expression' field for each link should be "<LHS> = <RHS>".
In each link replace the <LHS> with the Job parameter name, JobToRun.
In each link replace the <RHS> with the link name, "Job1", "Job2", or "Job3" (you need the double quotes this time).

Code: Select all

It should look like this when you get done:
Name     Expression Type               Expression
Job1     Custom - (Conditional)        JobToRun = "Job1"
Job2     Custom - (Conditional)        JobToRun = "Job2"
Job3     Custom - (Conditional)        JobToRun = "Job3" 
Click on the 'OK' button to close the dialog. Compile your job and run it. You should be able to choose which job you wish to run.

Good luck, and yell if you run into any problems.

Tony
huckinj
Participant
Posts: 3
Joined: Fri Sep 10, 2004 9:39 am

Post by huckinj »

Thanks for the help! I'll try this and ask more questions if I run into any issues.

-Jared
huckinj
Participant
Posts: 3
Joined: Fri Sep 10, 2004 9:39 am

Post by huckinj »

Tony (or anyone else who can help),

I tried the suggested method, and did get that to work. However, I would like to find a way to parameterize the child job without having to enter it in a prompt. For example, a previous step would assign a child job to the "JobToRun" variable, rather than DataStage prompting for the value. Is this possible?

Thanks,
Jared
tonystark622
Premium Member
Premium Member
Posts: 483
Joined: Thu Jun 12, 2003 4:47 pm
Location: St. Louis, Missouri USA

Post by tonystark622 »

Jared,

Can you describe exactly what you are trying to accomplish?

The method I gave you answers your original question (I think). The Job Sequencer is the "Parent job". You set the parameter when you run the Job Sequencer job and it determines which child job to run and runs it.

After rereading your last post, the only thing that I can suggest is yet another Job Sequencer or Batch Job (Batch jobs are non-GUI, code-only job controller jobs). This one would determine state and pass in the correct child job in the Job Parameter of the Job Sequencer you wrote.

Hope this helps,
Tony
Post Reply