cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practices for customizable Business Rules?

vwegert
Active Participant
0 Kudos

In a recent project, I finally had the opportunity to try out BRF+. With the help of several articles and on-line tutorials, I was able to create an application with a function and several other objects, generate the template code and integrate it into the remaining ABAP application. So far so good.

What I want to achieve next is a better separation of the rule set from the application. At the moment, the application code contains a hard-coded UUID that refers to the BRF+ function (and actually a second UUID for the import data object). This is OK as long as that application and the BRF+ function are always used in that combination. When delivering the application to another system landscape or another customer, this might not be we need: The other customer will have different business rules. At the moment, the only way to implement these rules would be to modify "our" BRF+ application, which is undesirable (especially since with every subsequent transport, there's a risk of overwriting the BRF+ objects again).

What is the recommended way to approach this? At the moment, all I can think of is some kind of customizing table that lets the customer specify another BRF+ application. However, this raises another set of questions: Can I somehow specify function names instead of (rather cumbersome) UUIDs? What do I do about the data object UUIDs? How do I ensure that the customers function has the same signature (input and output structure) so that I don't have to worry about runtime compatibility? Somehow I think that there should be something more sophisticated than a simple customizing table, but I don't know what to look for, exactly...

Thanks

  Volker Wegert

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Volker,

in general you can split your application into several ones and use the visibility of the applications (and the data objects stored in there). This way you can define one (typically S-) application that is globally visible,  where you just define the function and its signature. Another application can be created that contains the data obejcts (also globally visible - like a reuse package for gloabl data elements)

Concerning the call/delegation itself:

You can use a BRFplus decision table to define based on some input parameters which function to call. SO you have one facade-like BRFplus function that reads the decision table and determines the function to call. It finally delegates to the desired fuction using the function call expression. I would stick to the UUID of the function as it is the only unique value. Otherwise you run into trouble with non-unique names. The search dialog should allow you to search for the name instead of the UUID.

Concnerning the check of the signature. You can use an application exit in the application taht contains the facade function and the decision table. Within the exit you can check when storing/activating the decision table if the signature of the function stored in the decision table fits your needs using the BRFplus API.

What I do not get is the point with the UUID of the data objct of the signature. What do ou mean by that as it is not needed when calling the BRFplus application

BR

Christian

vwegert
Active Participant
0 Kudos

Hi Christian,

thank you for your response. Unfortunately, unless I'm missing something there, we're only moving the problem around instead of solving it. Let me try to express my problem with an analogy, perhaps that will make it clearer. I'll focus on the decoupling aspect first since I believe that's the critical one.

Let's say a developer provides an application that the customer shall be able to adapt. The developer provides an enhancement spot with a BAdI definition. That definition specifies the interface the customer has to implement - no choice! - and is something the developer can code against, even without knowing the exact details of the customer implementation. The customer in turn creates an enhancement implementation with a BAdI implementation, completely in his own namespace, and is forced to adhere to the interface specified by the developer. The "glue logic" to bring developer code and customer code together is provided by the basis / ABAP runtime system.

If I did as you suggested, that is using a Decision Table to emulate that "glue logic", that would have to be implemented either by the developer or the customer since it is not provided automatically. If the developer did supply that Decision Table, the customer would have to "modify" it and that modification might be overwritten with a subsequent delivery by the developer. Not good. If the Decision Table had to be supplied by the customer - apart from all other issues that might arise - the developer would not have anything to code against and test the (ABAP) application with.

Perhaps that illustrates the big question mark in my head - moving the decision which function to evaluate around to a different part of BRF did come to my mind, but unless I'm missing a piece of the puzzle, that's not going to decouple anything.

Thanks

  Volker

0 Kudos

Hi Volker,

the description of the problem is imho different now, so I will stick to the analogon of the BAdI although your last sentence makes me doubt a bit that this is 100% fitting, but I will  give it a try:

Requirement: The developer (e. g. of a partner solution) wants to provide some piece of code that the customer can adopt using BRFplus.

Solution: The developer has to define an application of storage type S (System) and choose the right visibility (as already mentioned I would use "global"). Within this application he has to define a function including context and result data object. This function has to use the event mode. All these objects are part of the globally visible application.

The developer has to implement the call of the BRFplus function in the code where it is fitting.

That is all. No definition of business content up to now, just provisioning a place to hook in rulesets and definition of an interface the developer can rely on.

Analogon: This corresponds to the definition of the BAdI interface and the call of the BAdI (Error handling like catching and treatingCX_BADI_NOT_IMPLEMENTED or for BRFplus CX_FDT included)

Requirement: The customer now wants to use the "enhancement" provided by the developer by hooking in his business rules modelled in BRFplus

Solution: The customer has to define an application (typically storage type C but all other storage types work too) and within this application he has to define a ruleset. He assigns the ruleset to the BRFplus function provided by the developer within the ruleset definition. He can now model the rules in this ruleset. Due to the assignment the data objects of the context and the result data object is available in customer implementation.

When the function gets executed the assigned ruleset is executed.

Analogon: The application corresponds to the enhancement spot in the BAdI scenario in the customer specific namespace. The assignment of the ruleset corresponds to the link between BAdI definition and the customer specific implementation in his own namespace/application

The sequence of multiple rulesets assigned to one function can be defined using the priority of the ruleset. There is no functionality comparable to the one of the BADI_SORTER, so you can only determine the sequence of multiple implementations during designtime, but not during runtime.

BR

Christian

vwegert
Active Participant
0 Kudos

Hi Christian,

thanks a lot, that answer does solve a few riddles. So in event mode, the BRF+ supplies the "glue logic" between the framework application and the customer code. (BTW, is this explained in Business Rule Management mit ABAP (SAP PRESS)? If it is, consider it bought ).

However, this might raise a slight complication: At the moment, the function is defined in function mode - it basically returns an integer value that is used to determine a sorting order. I'll have to read the documentation some more, I suppose...

Best Regards

  Volker

0 Kudos

Hi Volker,

usually it possible to  switch from functional mode to event mode (the other way round is not a that good idea). Nevertheless try it first with a "non-productive" function to test if everything works out fine (sometimes there are surprises e. g. due to missing notes). So this problem should be solvable

BR

Christian

P.S. The book describes the different modes in the second chapter

Answers (0)