This recipe shows how we can use the return codes from a child job to control the process flow in a schedule more effectively.
Open the job jo_cook_ch11_0050_ChildReturnCodes
. You will see that it is a simpler version of the job from the previous exercise.
We will begin by printing the return code from a child job.
Printing return code
Add a
tJava
component with the following code:System.out.println("Return code is: "+((Integer)globalMap.get("tRunJob_1_CHILD_RETURN_CODE")));
Link from the task to the
tJava
component using OnSubjobOk.Run the job—you will see that the return code is
0
.Setting the return code
Double-click on the child job to open it.
Add a
tDie
component, and link it to thetJava
component using OnSubjobOk.Open the
tDie
component, and change the code to4
. Now return to the calling (parent) job.Open the component tab for the task, and untick Die on error.
Run the job—you will see that the return code is
4
.Routing...