cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BRM - execution of different rules one after another

Former Member
0 Kudos

Hi at all,

I want to set up rules which get information from a rule fact named 'SpecParameter', process it and store it in the rule fact 'LocalParameter'.

So I have the following rule facts:

'SpecParameter' with the attributes 'name', 'description', 'unit', 'lsl' and 'usl',

'LocalParameter' with the attributes 'name', 'description', 'unit', 'lsl' and 'usl',

Additionally I have a rule fact named 'RuleFact' to store information about the execution of the rules itself:
'RuleFact' with the attributes 'ruleName', 'amountChecked' and 'amountExecuted'.

Before I process the attributes 'lsl' and 'usl' I want to fill the attribute 'unit' of the 'LocalParameter' if this attribute is empty.

Because there are special 'SpecParameter' and 'LocalParameter' identified by the name, I created three rules corresponding to these names:

Unit_RES,
Unit_RRG1 and

Unit_RRG2

So what I want is the following:

First execute the rule Unit_RES then Unit_RRG1 and then Unit_RRG2, every rule with the possibility of multiple execution.

For that goal I have created a rule flow in which the three single rules are lined up.

For every single rule I set the property loop and list the three different input objects.

But I got the following result:

<ruleFacts>

        <ruleName>Units_RES</ruleName>

        <amountChecked>63</amountChecked>

        <amountExecuted>2</amountExecuted>

</ruleFacts>

<ruleFacts>

        <ruleName>Units_RRG1</ruleName>

        <amountChecked>0</amountChecked>

        <amountExecuted>0</amountExecuted>

</ruleFacts>

<ruleFacts>

        <ruleName>Units_RRG2</ruleName>

        <amountChecked>0</amountChecked>

        <amountExecuted>0</amountExecuted>

</ruleFacts>

The exemplary rule for Unit_RES is as follow:

IF

{

    {

        RuleFact.getRuleName  Equals  Units_RES  

        and  RuleFact.increaseAmountChecked  Equals  true  

    }

    and

    {

        SpecParameter.getName  Equals  RES  

        and  FunctionsUtil.checkIfStringIsEmpty (   SpecParameter.getUnit   )  Equals  false  

    }

    and

    {

        FunctionsUtil.match (   RES.*   ,   LocalParameter.getName   )  Equals  true   

        and  FunctionsUtil.checkIfStringIsEmpty (   LocalParameter.getUnit   )  Equals  true  

    }

}

THEN

Execute :: FunctionsUtil.logMessageAsInfoUnsecure ( Rule Units_RES was fired. (A unit of a localParameter was set.)   )  

Execute :: RuleFact.increaseAmountExecuted  

Execute :: LocalParameter.setUnit ( SpecParameter.getUnit   )  

My Question is:
Why is only the first listed rule (in the rule flow) checked and executed and the other two rules are even never be checked.

Falk

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Somehow when I use a rule flow to invoke the three rules one after another only one rule is checked and executed.

When I put all three rules into a rule set and invoke these rules from an external direct call by 'ruleEngine.invokeRuleset(PROJECT_NAME, RULE_SET_NAME, inputObjects)' everything works as expected.

So my conclution is:
If I can not get the version with the rule flow to work (or someone give me a hint), I have to call the rule engine several times with different rule sets to reach the goal of invoking groups of rules one after another.

Falk