cancel
Showing results for 
Search instead for 
Did you mean: 

Question about Rule Design

ceedee666
Active Contributor
0 Kudos

Hi all,

after seeing and s presentation at the sitMuc I started to play around with BRFplus again. I'm currently trying to implement what is though was a simple requirement. However, after several days of experimenting, reading an thinking I still cant get it to run. What I'm trying to do is the following.

  • KeyKeyKey1I pass a table to BRFplus containing essentially key value pairs, e.g. something like that
    KeyValue
    Key1Value1
    Key2Value2
    Key2Value3
  • Using BRFplus I want to check if the table contains valid data. For my example I defined validity as the following set of rules:
    1. Exactly one entry with Key1 needs to be present
    2. Key2 is optional, but a maximum of one Key2 entries is allowed (by this rule the above example would not be valid)
    3. Value1 needs to be in a certain range, and, if present, Value2 as well.

What I did so far is to create Table Operation Expressions to check if only one entry with Key1 is present (expressions IS_KEY1_PRESENT) and if the optional Key2 is present (expression IS_KEY2_PRESENT). Furthermore, I created Table Operation Expressions to select and return the line containing Key1 (expression GET_KEY1_ENTRY)  and Key2 (expressions GET_KEY2_ENTRY) respectively.

That is where I'm stuck now. Conceptually I'd first need to create rules or expressions to work with the results of GET_KEY1_ENTRY and GET_KEY2_ENTRY. Next I would need to combine the expressions somehow (e.g. by using a ruleset or a decision tree)  in order to check my validity rules.However, I could not figure out a way of doing this.

Could somebody please suggest how to design the expressions and rules for what I'm trying to do?

Thanks,

Christian

ps.: I'm working on a 7.40 system.

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Kudos

Hi Christian

as far as I understand your scenario you are on track 🙂

So here is a proposal for a "design":

  • You have an application, a fucntion and a ruleset in place
  • Within the ruleset you first rule checks that exactly one entry with KEY1 is available. Here you use (as you already did) a table operation expression like:
    IF IS_KEY1_PRESENT <> TRUE
    THEN set an error flag/write an error message (depending on your result object of your function)
    In the ELSE Branch you can already read the corresponding table line via GET_KEY1_ENTRY
  • Then you use an EXIT condition in the result where you check if the first check failes (e. g. error flag = true) failed and conseqeuntly end the processing
  • The second rule contains (as you propose) the uniqueness check of KEY2 in analogy to KEY1 except that you also have to check that at least one line has to present.
    Here also use an EXIT condition for the error case
  • The third rule then (again checks )reads out the KEY2 if existent


Now you have made the basic checks and have the corresponding table lines to do the further checks

  • The fourth rule would then be the range check value range expression: IF the value of field IS NOT in the range etc. then error. The ELSE branch is empty You can then insert an exit condition for the error case in the ruleset.
  • The fifth rule would do the same if a KEY2 field is existent: IF KEY2 exists AND its range IS NOT valid (value range expression) then error. The ELSE branch is again emptyYou can then insert an exit condition for the error case in the ruleset.

Hope that helps

BR

Christian

ceedee666
Active Contributor
0 Kudos

Hi Christian,

thanks for for the help. I've one more questions. In order to store the results of the select table expressions I need some kind of variable. That means I have to add the structures to the context of the rule set. However, I haven't been able to create two variables with the same structure in the context of the rule set (one for each select table expression).

What is the best approach to do this?

Christian

christianlechne
Active Contributor
0 Kudos

Hi Christian,

to store this data I would use the (local) variables of the ruleset (not the global context).

Concerning the multiple assignement: yes this is indeed the case. So I would create two distinct dataelements (sounds a bit strange but I did not yet find a better way). If you use DDIC binding you can for sure assign the data objects to teh same DDIC type which causes a little less overhead for you.

BR

Christian

ceedee666
Active Contributor
0 Kudos

Thanks again for you help.

I finally figured out what my error was. I reused the structure created for the input table for one variable in the rule. This is not allowed (which is kind of counterintuitive for a programmer).

However, finally my scenario works.

Christian

Answers (0)