Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
manoharreddy478
Explorer
0 Likes
1,810

Function in BRF+:

A function is the rule interface in BRF+ and acts as a link between the application code and the BRF+ code. A function carries a context and a result. It imports the context from the calling application and passes the context data to the assigned top expression or ruleset for further processing.

Create an BRF+ application or chose the application in which you wanted to add function Expression. 

Right click on the application and select create > Function manoharreddy478_0-1752824529026.png

 

Provide the function name, text and short text.

manoharreddy478_1-1752824529027.png

Click on create and navigate to object to save and activate the object.  

manoharreddy478_2-1752824529029.png

 

Once clicked, it will navigate to the above screen. Here you have to assign the result data object based on the context data objects. 

Types of Mode: 

Function 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 subexpressions 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. 

Function and Event mode:

This mode is a combination of the modes mentioned above. At runtime, the function starts processing the assigned top expression. Once the expression evaluation is finished, function execution continues with the associated rulesets. 

Analytical Mode: 

It is mainly related to the Hana rules framework which is relevant to the runtime operations. 

 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 BRF+ function is invoked. Also, the context data objects of a function define the scope of objects that can be accessed by the expressions that are evaluated during function execution. 

  • Result 

The result data object returns a result value that has been calculated by the expressions of which the function consists . 

Note: For further in event mode, the result object is automatically set to the predefined actions table where the actions are recorded that have been triggered by the assigned rulesets. 

Code Generation:

BRF+ provides a built-in code generation facility used to compile source code for as many rule constructs in a function as possible. With the help of generated code, BRF+ rules can be executed significantly faster than in interpretation mode. 

Simulation: 

You can simulate the function processing to test the function's behavior in a sandbox environment. Here, you can gain an in-depth insight into the system status for every single step the system takes during function processing. 

Trace

In BRF+, you can request the system to create a processing log to keep track of all processing steps during function execution. The trace information is stored in the system and can be reviewed at any point in time. 

Trace will be stored in Trace tables FDT_TRACE_*

Generation Services

For a BRF+ function, you can take advantage of different services that automatically generate code and other objects that are needed to bridge the gap between the ABAP backend system where a BRF+ function is hosted and other systems or environments that wish to access BRF+. The different services available address different usage scenarios. These can be categorized as follows: 

  • Code Templates 

A code template is a predefined snippet of ABAP code that you can use to call a BRF+ function from your application in the same system. 

  • Generate  
  • Function Module 

You can use a generated RFC-enabled function module to call a BRF+ function that resides in a remote backend system. This is useful in cases where you cannot bring BRF+ and the calling application into the same system — be it for technical reasons (for example, different releases) or for organizational reasons (for example, missing authorization to develop in the remote system). 

  • Web Service 

You can use a generated web service to call a BRF+ function from a web application that is not ABAP-based, or that you can only integrate via its exposed services interface. From a technical point of view, web service generation is reusing the function module generation component of BRF+ and generates additional system objects needed for service enablement. 

Here we will work on Function mode example: 

 

manoharreddy478_3-1752824529030.png

Assign the top expression and in context add the required objects and finally assign result object suitable. 

Top Expression:  

Its is pre-condition of the function which will evaluate the number of nested expressions to find the result. 

To execute the function click on simulation. 

manoharreddy478_4-1752824529031.png

Click on continue 

manoharreddy478_5-1752824529032.png

Select the input true or false and click on execute 

Result : 

manoharreddy478_6-1752824681872.png

Note : All the objects created will be stored in FDT_* tables 

Conclusion: 

Function provides a built-in code generation facility used to compile source code for as many rule constructs in a function as possible
Function is the most important BRF+ object and it represents a decision service , which is the element that is in fact invoked by the application and the entire application is invoked by function to stimulate and provide the output we can invoke using the code generation to create report program for executing in GUI.
we can perform pre-conditional and event of action related condition's like rules for executing in the based on the specified rule using the type of modes in the function expression.