Functional Mode

In Functional Mode, the typical process flow is as follows:
- Application Creation: Begin by creating an application.
- Function Creation: Next, create a function.
- Data Object Creation: Set up data objects used in the application.
- Expression Creation: Create a top expression and assign it to the function.
- Context and Result Assignment: Assign data objects to both the context and result of the function.
- Object Activation: Activate all relevant objects.
- Simulation Run: Simulate the function as a unit test.
- Integration: Finally, integrate the BRFplus application and function with your business process application.
Event Mode

In Event Mode, the typical process flow is as follows:
- Application Creation: Begin by creating an application.
- Function Creation: Next, create a function.
- Data Object Creation: Set up data objects used in the application.
- Context and Result Assignment: Assign data objects to both the context and result of the function.
- Ruleset(s) Creation: Create ruleset(s) for the function.
- Rule Creation: Create rule within the ruleset.
- Expression and Action Creation: Create the expression and/or action and assign to the rule.
- Object Activation: Activate all relevant objects.
- Simulation Run: Simulate the function as a unit test.
- Integration: Finally, integrate the BRFplus application and function with your business process application.

To be able to successfully run a Function in Event Mode, you need to:
- Set the Function Mode to Event Mode.
- Assign Ruleset(s) to the Function, which contains the rules that will run on the data.
- Set up Function Context - Signature for passing the data to and from BRFplus
- Set the Result, as needed.
Note
You can set the Result to "Actions" for BRFplus in Event Mode. BRFplus in Event Mode can perform actions in the system, such as posting documents, managing master data, creating tax, or filing obligations, correspondence requests, workflows, and so on. Therefore, in this scenario it is not expected that Functions running in Event Mode return any particular values to the calling program.
Function Context and Result Data Object
Context and Result serve as the interface in BRFplus, facilitating data exchange between calling programs/business processes and BRFplus Functions.
- Input Parameters: Input parameters are assigned within the Context section.
- Output Parameters: Output parameters are assigned within the Result Data Object.

Data objects within Context and Result can take the form of Elements, Structures, or Tables.
- Element Data Objects: These can be of types such as Text, Number, Boolean, Quantity, Amount, and Timepoint.
- Structure and Table Data Objects: These follow the same principles as classical ABAP.
Attributes defined in the Context serve as input values for processing by a Function or an Expression. The Context can comprise one or multiple elements, structures, or tables, each accessed by its name.
In contrast, a Function or Expression can have only one Result Data Object. However, if a business rule needs to return multiple values simultaneously, this can be achieved by assigning a structure or table as the Result Data Object.
The Context data of a function can be utilized by all sub-expressions belonging to the function's top expression. Input parameters of the expressions are populated either with the function's context or with the results of other expressions.
Function Features and Capabilities
On the Function level, you have access to the following:
- Simulation
Built-in simulation allows rule modelers to test the correctness of BRFplus functions in a controlled environment.
- Debugger
Analyze the function execution in detail, using debugger functionality.
- Traces
Trace the input and output of each rule, in sequence of execution within the function.
- Generate - RFC module or Web Service
Generates function code suitable for remote/API calls - service-oriented environments.
- Create Code Template
Generate ABAP code for calling the function from external sources (ABAP).
- Advanced Checks
Semantic check Rulesets assigned to the function, unversioned objects and inactive objects.
Note
Features
- Mode of Operation: A function can be designed for one of the following modes of operation:
- Functional Mode: In Functional Mode, function execution starts with the assigned top expression. From this top expression, the processing may run through any number of nested sub-expressions until a result is returned.
- Event Mode: In Event Mode, the function is associated with a list of rulesets that are executed according to their execution priority and their position in the list.
- Signature: The function signature consists of two parts:
- Context: The context is a container for data objects that you can assign as import parameters for the function. You choose the context data objects of a function according to the requirements of the calling application by which the BRFplus function is invoked.
- Result: The result data object returns a result value that has been calculated by the expressions of which the function consists. Note that for functions in Event Mode, the result data object is automatically set to the predefined Actions table where the actions are recorded that have been triggered by the assigned rulesets.
- Code Generation: BRFplus provides a built-in code generation facility used to compile source code for many rule constructs in a function as possible.
- Simulation: You can simulate the function processing to test the function's behavior in a sandbox environment. Here, you can get an in-depth insight into the system status for every single step the system takes during function processing.
- Trace: In BRFplus, you can request the system to create a trace log in order to keep track of all the events that may arise during function execution. The trace information is stored in the system and can be reviewed at any point in time.
- Web Services: BRFplus supports the generation of web services for a function. This enables you to integrate the rule execution power of a BRFplus function into a service-oriented software environment.





