In contrast to status
evaluation, decisions can be used to route the process flow by means
of evaluated expressions based on real-time business data values.
Decision gateways in SAS Workflow Studio contain Boolean expressions
that drive actions based on the calculated value. Thus, decision nodes
can be used to route process execution to one (Workflow Pattern: Exclusive
Choice) or more (Workflow Pattern: Inclusive Choice) of several alternate
outgoing paths, depending on the condition.
To add and configure
decisions, follow these steps:
-
Select the Add Decision
Gateway icon (
) on the toolbar.
-
Click on an empty space
in the drawing area to add a decision gateway to the diagram.
To define the properties
of a decision node, follow these steps:
-
Right-click on the figure
in the drawing area and then select
Edit.
Alternatively, double-click
on the decision node.
-
In the
Edit
Decision Gateway dialog box, enter the desired values.
-
Enter a name for the
decision in the
Label field. The default
name of the first decision is
Decision0
.
The second decision is
Decision1
, and
so on.
-
To define Boolean expressions
for a decision node, follow these steps:
-
Select
Add to
open the
Add Boolean Expression dialog box.
-
Enter the desired logical
expression.
-
(Optional) Provide a
name for the expression in the
Label field.
(The default value is
the expression itself.)
-
Select
OK to
save the current expression.
The newly defined Boolean
expression should be visible in the list box.
Repeat these steps to
associate additional Boolean expressions with the current decision
figure.
-
Select
OK to
save the decision definition.
All expressions must
evaluate to a Boolean value and must conform to the Java language
syntax. In summary, each expression must comply with the following
rules:
-
The expression must evaluate to
true or false.
-
The expression can use comparison
operators (
<
,
=
,
==
,
or
>
).
Note: The
=
and
==
operators
are evaluated in an identical manner.
-
The expression can contain logical
combinations (
&&
,
||
,
!
)
of some set of comparisons.
-
The expression can contain arithmetic
expressions on each side of the comparison. The arithmetic expression
can be any combination of the following operators:
+
,
-
,
*
,
/
,
or
%
. Arithmetic expressions can also contain
functions, integers, floating point numbers, and data objects.
Data objects are specified
by their label and might contain spaces.
Tip
To use data objects when writing
Boolean expressions, press the F3 key to access a menu of valid data
objects for the current process.
Tip
Use the
Edit and
Delete buttons
to modify the contents of the list of expressions.
To assign the expressions
to the relevant process paths, follow these steps:
-
Ensure that you have
defined all the required Boolean expressions for the decision gateway.
-
Define the necessary
process paths.
-
Connect the decision
to the relevant activities for each path.
-
For each connection,
right-click on the connection, select
Change status,
and select the appropriate expression.
Each expression corresponds
to a calculated value or outcome and is represented as a label in
a similar manner to status values. In addition to these user-defined
calculations, the special status of
Otherwise
can
be assigned. Use this value to designate the logical path that should
be traversed when all defined expressions evaluate to false. In summary,
the
Otherwise
path represents the default
execution path when none of the expression values are true.
Note: All paths with expressions
that evaluate to true are executed.
For the following example,
any order total that exceeds $500 requires manager approval before
it is fulfilled. The decision gateway is based on an Order Total data
object of type Number where the
Yes
path
corresponds to a value exceeding the threshold and
No
,
where the order total is below the threshold, is approved automatically.
|
|
|
|
|
Requires Manager approval
|
See the examples provided
with SAS Workflow Studio for details of this example.
For a process flow where
one or more paths from a decision can be followed at the same time,
an inclusive choice decision might be used. For example, a mail order
company receives orders with combinations of items (books, music [CDs],
movies [DVDs]) with distinct fulfillment activities initiated for
each item type. A typical order contains quantities of more than one
product type.
However, this divergence
pattern (Workflow Pattern: Inclusive Choice) has two potential problems:
-
There is a deadlock if none of
the choice expressions are realized.
-
Convergence requirements might
be complex resulting in deadlock or surplus executions.
The first issue can
be resolved by providing a default path. SAS Workflow Studio supports
this with the (Otherwise) choice, which is available with all decision
gateways. Most importantly, the business logic must be captured accurately
and should cover all possible outcomes.