Application Development 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: 
former_member224404
Active Participant

Introduction -

BRFplus is a webdynpro application delivered by SAP from Netweaver 7.0 onwards and it brings a new way to design and develop business rules outside from ABAP program. In the following section, I am giving a sample scenario and I will demonstrate how I have used BRFplus to implement that business rule.

Scenario –

We are planning to calculate customer price differently for low-quantity metal trades i.e. 0 to 50 ozt. So the condition will be:

If quantity = 0 to 50, unit = OZT, and Metal = Gold, Silver, Platinum, Palladium then customer price = Quote price * 1.10

Otherwise, quantity = 0 to 50, unit = OZT, and Metal = Rhodium, Ruthenium, Iridium, the customer price = Quote Price * 1.70.

Solution –

   1. Execute transaction code BRFPLUS once logged in to SAP.

   2. This will open up a web page that looks like following. First we need to create an application if not created already. This can be done by going to the repository tab in the navigation panel and clicking on the button ‘Create Application’ or from the Workbench menu.

   3. Next step would be to create a function and this can be achieved by right clicking on the application and choose function like the following –

   4. The signature of the function is developed by creating 3 elements viz. metal, quote price in ounce and quantity in unit OZT and the result data object will be the customer price.

   5. Next, ruleset needs to be assigned to the function. Please click ‘Assigned Rulesets’ tab in the screenshot above and click on the ‘create ruleset’ button.            Give a name to the new ruleset and you will get the following screen.

    6. Now create a decision table by right clicking on the TMS_PM application and choose the following context menu.

 

  7. Create the following condition column and result column details in the decision table –

8. Besides, create the following context variable from the context variable already created inside the function CALCULATE_CUSTOMER_PRICE in step 3.         This will be used in the decision table –

9. After the decision table has been created, create the following entries in the decision table like the following screen shot –

10. Now go to the Repository and expand the ruleset and click on the ruleset Automatic Customer Price.

11. Click on Insert Rule button in the bottom left corner of the screen and you need to enter the context value(CUSTOMER_PRICE) and decision table(DTAB_CUST_PRICE) created earlier and finally it will look like below -

12. That completes the BRF rule creation for this requirement. Now we need to call the rule from ABAP program. BRF function can be called from ABAP program and the code can be generated from report FDT_TEMPLATE_FUNCTION_PROCESS. You need to get the id of the BRF function which can be found as ID in the general tab which is shown below –

13. Copy the ID and then execute report FDT_TEMPLATE_FUNCTION_PROCESS and in the selection screen paste the ID to the function id parameter field and execute. This will provide the template code ready to be used –

14. The code is pasted in a FM and the context variables are replaced by importing/exporting parameter values of the function module and then activated.

Test –

  1. Passing metal = AU, quantity = 10 OZT, Quote price = 100 USD and the output comes 110 USD

2. Passing metal = IR, quantity = 10 OZT, Quote price = 100 USD and the output comes 170 USD.