cancel
Showing results for 
Search instead for 
Did you mean: 

Using a Structure data-object as the result of a Search Tree

SuhaSaha
Advisor
Advisor

Hello,

I am modelling a BRF+ "Search Tree" for calculating the BuPa credit worthiness.

The algorithm looks something like this:

  • Check1: If true, RESULT-RATING = 'A1' + RESULT-SOURCE = 'Check1' ; ELSE
  • Check2: If true, RESULT-RATING = 'A2' + RESULT-SOURCE = 'Check2' ; ELSE
  • ...
  • Checkn --> If true, RESULT-RATING = 'An' + RESULT-SOURCE = 'Checkn' ; ELSE
  • Default rating

Basically the structure contains the credit-worthiness score and additional details of the check.

I am not sure how to populate the structure 😞

Is there any built-in BRF+ expression which can do the structure mapping? (similar to the mapping done in procedure call)?

Any pointers will be appreciated.

BR,

Suhas

SuhaSaha
Advisor
Advisor

There is no direct way to map the structure fields in BRF+.

But as mike.pokraka has pointed out, if the number of conditions are finite(read: can be managed manually) then one can use decision tables to fill a structure. The columns of the result structure then become the "result columns" of the decision table.

In my case, the credit-worthiness score needed to be saved in the DB. Therefore i defined the result the "Search Tree" as actions(instead of variables). In the action called an "ABAP Procedure" to update the DB.

Accepted Solutions (1)

Accepted Solutions (1)

pokrakam
Active Contributor

Search trees allow for dynamic conditions but have rigid results. Decision tables do the opposite - the search criteria are fixed but results can be highly flexible. As I understand, you want a combination of both.

I would implement this as two expressions in a ruleset with local context data. The search tree provides the result and passes it on to a decision table which populates the returning expression in the format you need.

SuhaSaha
Advisor
Advisor
0 Kudos

The search tree provides the result and passes it on to a decision table which populates the returning expression in the format you need.

I already have two solutions in my mind:

  • I could delegate the task of filling up the structure to a ABAP Procedure (Procedure call expression). Isn't it easier than calling a decision tree?
  • Instead of a "data-object" as a result-type of the Search Tree i could use "Action". As action i could call a ABAP Procedure.

IMO in my case calling a ABAP procedure is acceptable, because there's no business rule involved there!

I want to know if there was a easier way to do this. All i want is to fill up a structure & not an element.

BR,

Suhas

pokrakam
Active Contributor

Multiple expressions in a ruleset is very straightforward. As a general strategy, breaking a rule down into sequential parts is exactly what rulesets are designed for, and I don't see how adding a procedure call expression would make it easier.

Personally I see ABAP method vs. other BRF+ expressions a bit differently. If it's business data then avoid ABAP calls, as they turn things into a black box and make debugging more difficult. A decision table makes it clear to everyone what is going on.

SuhaSaha
Advisor
Advisor
0 Kudos

Multiple expressions in a ruleset is very straightforward. --> True, the search tree in our case has expressions all over the place - boolean, loop, table expressions, function calls etc. It's a really complicated expression!

If it's business data then avoid ABAP calls, as they turn things into a black box and make debugging more difficult. --> We need to read business data based on the "check" we are performing. We use ABAP calls to load the data into the BRF+. I think it makes sense to load the data when (or if) needed & not load everything at once. Again no business logic there, just fetch data for the partner & supply it.

I agree with the "black box" comment & therefore i don't wanna use my solution!

Anyway, isn't there an expression to map a structure?

pokrakam
Active Contributor
0 Kudos

I agree, and another way to differentiate is that ABAP calls are useful to push technical logic into the ABAP layer, which sounds exactly like what you're doing.

"isn't there an expression to map a structure?" -> No, that's what I suggested to use a decision table for. It will work well if it's a finite number of entries (and not too many). It could be a candidate for a custom expression type, or perhaps implemented as a BRF+ function. But then I don't see too many use cases.

Is there a reason you can't return a structure from your expressions to start with? Perhaps using a decision tree instead of a search tree? Or how about slicing your rule in other ways? e.g. If it's returning a category and a set of values, then perform the category determination in a tree and do the value calculation(s) in a decision table.

I don't know your scenario, so these are just a few ideas...

Answers (0)