On
Success and On
Failure branch options allow better control on the
conditional flow of jobs running in a batch.
This can be expressed as a collection
of nested ‘if’ statements, e.g.
function RunBatch
{
if (job = true or continue
processing option enabled) then
if
(job = true or continue processing option enabled) then
if ...
.
.
.
return last job status
}
Each job record has two columns, OnSucessJobID
and OnFailureJobID.
These can optionally refer to any job in the batch including the current
job. Specifying the current job ID
in the OnFailure column provides retry capability.
If both columns equal null then the
behaviour is determined by the processing options. Otherwise, at run time, depending on the return status of a
job, SLIK selects the job to branch to. This
logic can be represented as:
Function RunBatch
{
for each job
{
status
= run job
if
(status = true and OnSucessJobID is not null) then
GotoJob(OnSucessJobID)
else
if (status = false and OnFailureJobID is not null) then
GotoJob(OnFailureJobID)
else
if (status = false and not continue processing option enabled)
return false
}
Note:
the Goto job
function
repositions the cursor (i.e., pointer to next/current job) at the first enabled
job greater than or equal to the specified job.
Therefore, even if the specified job is currently disabled then the Goto
operation will find the first enabled job based on the job sequence.
Processing then continues from this point on until either reaching the
last job in the batch or encountering a "Halt Batch" operation.
The system tracks how many times a job
has executed over a batch run and detects infinite recursion.
Specifying a “Recursion Count
” value in the batch can control this recursion.
If the Recursion Count column is null then it defaults to a maximum
recursion count of three job runs before aborting the batch.
If the recursion count value is zero then this indicates there is no
limit on the number of times a job may run in a batch.
Otherwise the value specified determines the maximum number of times a
given job can run in the batch.
An unconditional branch can be
achieved in one of two ways. The
same job can be specified in both the OnSuccess and OnFailure column.
Alternatively the job has the "Continue Processing" option set and the
next job is a "Goto Job" operation.