Decision Tables [ HP ALLBASE/4GL Developer Reference Manual Vol. 2 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 2
Decision Tables
HP ALLBASE/4GL decision tables allow you to define a series of
interrelated decisions and the actions to be taken as a result of those
decisions. Decision tables can be regarded as being equivalent to
multiple levels of IF-THEN-ELSE statements in a conventional language.
A decision table consists of three major elements:
* Decision table questions.
* Decision table actions.
* Decision table relationships.
Each decision table can test up to eight different questions. The
decision table questions are simple IF statements. Each IF statement can
test two operands for equality or otherwise, or test a single operand or
switch for its status.
The decision table actions are any actions that you can call from a menu.
They are:
B background process
D menu or data screen
F function
H help screen
P process
R report
X external program
The decision table relationships define up to 31 different combinations
of outcomes for the decision table questions. For each combination of
outcomes, the decision table relationships define the actions to be
performed and the sequence in which the actions are performed.
You can think of a typical decision table as being a table in the
following format.
-------------------------------------------------------------------------------------
- Question - Columns -
-------------------------------------------------------------------------------------
- - 1 - 2 - 3 - 4 - ... - 31 -
-------------------------------------------------------------------------------------
- 1 - Y - - - N - N - - Y -
- 2 - Y - Y - N - Y - - Y -
- 3 - N - Y - - - N - - - -
- 4 - N - N - Y - N - - Y -
- 5 - - - Y - N - - - - N -
- 6 - - - N - Y - Y - - Y -
- 7 - Y - Y - - - - - - - -
- 8 - N - N - Y - Y - - N -
-------------------------------------------------------------------------------------
---------------------------------------------------------------------------
- Actions - Order of Execution -
---------------------------------------------------------------------------
- 1 - 1 - 8 - 2 - 0 - - 4 -
- 2 - 2 - 5 - 1 - 1 - - 3 -
- 3 - 3 - 2 - 0 - 0 - - 1 -
- 4 - 4 - 7 - 0 - 0 - - 5 -
- 5 - 5 - 3 - 0 - 0 - - 0 -
- 6 - 6 - 4 - 3 - 0 - - 0 -
- 7 - 7 - 1 - 4 - 0 - - 2 -
- 8 - 8 - 6 - 0 - 0 - - 0 -
---------------------------------------------------------------------------
Each column in this table defines one possible combination of outcomes
for the decision table questions, and the actions to be performed if this
particular combination of outcomes occurs.
Within each column you can specify that for each question the outcome
must be true (Y), false (N), or don't care (-). The numbers in the lower
part of the table define the actions that the table executes, and the
order of execution of the actions if that combination of outcomes occurs.
The number 0 indicates that the corresponding action is not executed for
that particular combination of outcomes. For example, in the above
sample table, the entries in column number 3 specify that action number 2
is executed first, followed by action number 1, action number 6 and
action number 7 in order. Actions number 3, number 4, number 5, and
number 8 are not executed.
The order of execution of the decision table actions does not depend on
the number of the action or the order of entry.
When HP ALLBASE/4GL executes a decision table, it scans the columns of
the table starting from column number one. HP ALLBASE/4GL checks each
column until it finds a column that matches the actual outcomes of the
decision table questions. HP ALLBASE/4GL then executes the actions
defined for that column, and terminates the decision table.
To define a decision table, you need to complete four screens. They are:
* The decision table header screen.
* The decision table questions screen.
* The decision table actions screen.
* The decision table relationships screen.
Each of these screens allows you to define part of the decision table.
The decision table header screen allows you to define the name of the
table and enter a description for documentation purposes.
The decision table questions screen and the decision table actions screen
allow you to define the questions the table tests, and the actions the
table can execute. However, these screens do not define the combinations
of outcomes of the questions, or the sequence of execution of the
actions.
The decision table relationships screen allows you to step through the
table one column at a time, and define the contents of each column. For
each column of the table, you can define the required answer for each
question as true (Y), false (N), or don't care (-). For each column, you
must also define the actions to be performed if that combination of
outcomes occurs, and the order of execution of the actions. You don't
need to complete all 31 columns of the table if your application doesn't
need that many. However, the columns must start from number one, and
must be sequentially numbered.
MPE/iX 5.0 Documentation