Applying conditional branching logic

A conditional dependency is a relation that uses the status or output of a previous job to determine whether a specific segment of your job flow executes.

With IBM® Workload Scheduler you can define jobs to run as often as necessary. Sometimes some jobs must wait for other jobs to finish successfully before they start. Add flexibility to your job flows by choosing which job to run based on the status or output of a previous job.

You can specify dependencies to define job flows with alternative branches based on conditional logic. This behavior duplicates the function of if-then-else statements. To determine when a successor job starts, you can use return codes, job status, output variables, and job log content as conditional logic elements.

The Graphical Designer within the Dynamic Workload Console displays a visual representation of these relationships, dependencies, and conditions. You can use the workspace to quickly view and modify your job flows.

Note:

Conditional dependencies are evaluated after any standard dependencies in the job or job stream are satisfied.

Example:

The PAYROLL job stream starts with the ABSENCES predecessor job, followed by two conditional branches of jobs that can run. The branch that runs depends on the outcome of the ABSENCES job, as defined by its output conditions.

If the output conditions are not satisfied, the IBM Workload Scheduler places the omitted successor jobs in the SUPPRESSED state. This behavior differs from regular dependencies, where the system places successor jobs in the HOLD state until the predecessor reaches a successful (SUCC) state. Predecessors can be either jobs or job streams.
A job stream showing a predecessor job that then branches out to two different successor jobs
You can define two types of conditions: status conditions (based on job status), or other output conditions (based on a mapping expression such as a return code, output variables, or output in a job log content). When the predecessor is a job stream, the conditional dependency must be a status condition.
Status conditions
Status conditions evaluate the run state of a job or job stream:
  • For jobs, valid states include FAIL, ABEND, SUCC, or SUPPR.
  • For job streams, valid states include SUCC, SUPPR, and ABEND.
Other output conditions
You can evaluate other output conditions by using a mapping expression based on the agent type:
  • A return code (available on fault-tolerant agents and dynamic agents)
  • Output variables (available on dynamic agents)
  • Job log content (available on dynamic agents)

A condition establishes a conditional dependency relationship. You specify output conditions directly within the job definition, and you can define an unlimited number of dependencies. When you add a conditional dependency to a job, you select the exact status and output conditions that the system evaluates during processing.

Example:

The following example illustrates other output conditions defined within a job definition:


Job properties General Information tab displaying other output conditions set in the job definition.
You can define both successful output conditions (which signify a successful job run) and alternative output conditions (which determine which successor job starts). IBM Workload Scheduler evaluates these output conditions using OR logic.

When you add this job to a job stream as a successor job and apply a conditional dependency to the preceding job (the predecessor), you select the required conditions. The Properties panel for the internal or external dependency dynamically updates to include the conditions from the job definition. In addition to these default conditions, you can select conditions based on job status. If the selected conditions are satisfied during job processing, the corresponding successor job runs.


Properties of an internal job dependency showing the conditions that were previously set in the job definition

You can aggregate or join conditional dependencies from different predecessors. A join contains multiple dependencies, and you specify how many of those dependencies must be met for the system to consider the join satisfied. You can define an unlimited number of conditional dependencies, standard dependencies, or both within a single join.

Conditional dependencies are not supported on internetwork dependencies, nor on Limited Fault-Tolerant Agents for IBM i.