Entering content frameBackground documentation When Is a Rule Executed? Locate the document in its SAP Library structure

General Criteria

A rule is executed in the EH&S Expert under the following conditions:

Note

Explicitly intervening in the processing of a set of rules by means of Enable and Disable commands can lead to facts of rules that have already been executed being subsequently changed. This results in the rule being executed again.

Exceptions:

Exception: ToDos that only make direct assignments of the kind X:=Y can also be executed if Y has the value zero, or in other words, has no real value.

The system finishes analyzing whether rules are to be executed when no more rules fulfill these conditions.

Example

 

X := 1

Default: Facts X and Y have data, Z is empty (null).

 

Y := 2

 

Z

 

RULE R1

The condition X=1 is true. The rule is therefore executed and the rules of rule group Group1 are deactivated.

   

IF X = 1

   

THEN DISABLE(GROUP1)

 

END

 

RULE R2 GROUPS GROUP1

The rule was deactivated by rule R1 and can therefore not be applied.

   

IF X > 0

   

THEN Z := 1

 

END

 

RULE R3

This rule can be applied as the empty Z does not appear in a complex expression.

   

IF TRUE()

   

THEN Y := Z

 

END

 

RULE R4

Rule cannot be applied because Z has no value within the expression Z + 1.

   

IF TRUE()

   

THEN Z := Z + 1

 

END

 

RULE R5

The empty Z is part of the condition and the rule therefore cannot be applied.

   

IF Z = 0

   

THEN Y := Z

 

END

 

RULE R6

This rule can be applied as the empty Z appears within the IsNull() function.

   

IF IsNull(Z)

   

THEN Z = X

 

END

 

RULE R7

This rule cannot be executed because the condition is not true.

   

IF X > 10

   

THEN X := X + 1

 

END

Data-Dependent Rule Execution

The strategy of data dependency applies to the sequence in which rules are executed. This means that if rule A can be executed according to the criteria not yet executed and not deactivated, before checking the other criteria relevant to the data, the system first executes all the rules that could change the value of facts that are used in A as input data. These facts are those that appear in the condition or to the right of assignments.

Data-dependent rule execution is performed recursively. In other words, if when checking rule A the system determines that rule A requires data from rule B, but rule B is dependent on data changed in rule C, then rule C is executed first, followed by rule B, and then rule C.

The rule editor shows you the dependencies that exist between rules using the following color conventions. Choose the required presentation mode under Debug ® Visualize Recursive Rule Dependencies.

Color

Single-Level Dependency Mode

Multilevel Dependency Mode

Blue

Selected rule

Selected rule

Red

Rule on which the selected rule depends directly

All rules on which the selected rule depends

Green

Rule that depends directly on the selected rule

All rules that depend on the selected rule

Gray

All rules that have no direct connection to the selected rule

Rule that has no connection to the selected rule

When performing this dependency check, if the system determines that the search ends back in the starting rule, the search is terminated and the system begins with the execution of the last rule to be identified, thus avoiding an endless loop.

The rule editor gives you the option of checking for circular dependencies. To do this, choose Tools ® Check Circular Dependencies.

Example

Here is an example of data-dependent rule execution:

 

X := 1

Default: Facts X and Y have data, Z is empty (null).

 

Y := 2

 

Z

 

RULE R1

Before checking the condition of this rule, the EH&S Expert first searches for rules that could change the value of X. X is used not only in the condition, but also to the right of an assignment.

   

IF X = 1

   

THEN Y := X

 

END

 

RULE R2

This rule changes X (X is on the left of an assignment), but X is dependent on the value of Z. Therefore the Expert searches for rules that change Z.

   

IF Z > 0

   

THEN X := 1

 

END

 

RULE R3

This rule sets the value of Z and is not dependent on any other input data. In other words, the dependency check has finished. The EH&S Expert executes rule R3 and then rule R2 as no further rules can change Z. Finally rule R1 is executed as the value of X is now established.

   

IF TRUE()

   

THEN Z := 5

 

END

Explicit Dependency

You can also directly influence the rule execution process in other ways (see Control of the Rule Execution Process).

Note

The sequence of rules in the set of rules is therefore only relevant to a certain extent.

 

 

 

Leaving content frame