Skip to Content
Author's profile photo Rajwin Singh Sood

BRFPLUS in SAP CRM WEBUI Framework

/wp-content/uploads/2014/07/pic1_499073.jpg

Applies to:

SAP CRM 7.0, EHP1 and EHP2

Summary

This particular document illustrates the step by step methodology of first creating business rules in BRFPLUS and then using the same business logic in SAP CRM WEBUI Framework in the form of BSP component and view. The actual scenario was quite complex where we had the Product price validation into the picture. In short we had the scenario where we had to pick up the price of the product(coming from VMC) and the product which was passed to the BRF Plus and then certain validations were done as per client requirements to classify the product and then have it shown in the WEBUI. As the actual scenario was difficult to recreate and share I had illustrated the same using the scenario of student results. In this scenario user needs to enter the subject, actual marks and total marks in the table provided by BRFPLUS and in return BRFPLUS will calculate the total marks and percentage and also will be sending an email intimating that the result has been dispatched. The email part in BRF plus in the original scenario was used in order to communicate to the user with respect to classification of the product.

NOTE: – This particular document is intended for audiences who has basic knowledge about BRFPLUS. For BRFPLUS basic knowledge one can refer to the BRF PLUS SCN link given below:-

http://scn.sap.com/docs/DOC-8824

Author(s): Rajwin Singh Sood

Company: Atos

Created on: 15th July 2014

Author Bio

/wp-content/uploads/2014/07/pic2_499074.jpgRajwin Singh Sood is currently working as Team lead/Solution Architect at Atos. He has got experience of more than 9 years in SAP ABAP and SAP CRM web UI. He is also a SAP CRM EHP2 Certified associate consultant. Prior to working with Atos he had worked with SAP India(SAP Global Delivery), Capgemini , Accenture and Infosys. He worked in SAP CRM Web UI areas like BSP enhancements, transaction launchers, BOL Programming, BRFPlus .

Steps for creating the business rules and scenario in BRFPLUS

As specified in the summary section we’ll be using the simple student result scenario where in user will input subject, actual marks and then total marks in return BRF Plus. The steps given below highlights the things to be done in BRF Plus to set up the Business rules and the scenario as such:-

1.Type the transaction BRFPLUS and press enter.

/wp-content/uploads/2014/07/pic3_499075.jpg

2.   The browser the BRFPLUS workbench opens up. As a first step create a new application and save it as student result and then activate it as per the below screenshot:-

/wp-content/uploads/2014/07/pic4_499079.jpg

3.Third step we need to create a BRFPLUS function which is the starting point in BRFPLUS. This function is very much similar to the function module in SAP ABAP with importing and exporting parameters. Over here first we’ll create a function and assign the import and export parameters in the signature as per the below screenshots:-

/wp-content/uploads/2014/07/pic5_499080.jpg

Here the Data Input is nothing but table type data object which is used as import parameter for the user to enter subject, maximum marks and actual marks. Data input is defined as the table type which has Data dictionary table type structure ZSTUDENT_RES_DATA:-

/wp-content/uploads/2014/07/pic6_499081.jpg

/wp-content/uploads/2014/07/pic7_499085.jpg

4.The export/returning parameter is a structure type data object whose type again is defined data dictionary of type ZSTUDENT_FINAL_RESULT:-

/wp-content/uploads/2014/07/pic8_499086.jpg

5.Now comes the step where we need to define the rulesets in BRFPLUS which is nothing but the logic which we need to define for calculating the result on the basis of data entered by the user.

/wp-content/uploads/2014/07/pic9_499087.jpg

/wp-content/uploads/2014/07/pic10_499121.jpg

6.Now in the rule set we’ll define the condition check_input_data which is just to check whether the user has input any data in order to calculate the result. Its nothing but table operation in BRFPlus for Count similar to Select COUNT(*) in SAP ABAP

/wp-content/uploads/2014/07/pic11_499122.jpg

so from select operation select count and in the section from table select data_input which is the importing parameter

/wp-content/uploads/2014/07/pic12_499123.jpg

/wp-content/uploads/2014/07/pic13_499157.jpg

and the return parameter will the data object of type numeric:-

/wp-content/uploads/2014/07/pic14_499158.jpg

/wp-content/uploads/2014/07/pic15_499159.jpg

7. Now after creating the condition in the ruleset now we’ll define the steps/operations which we need to perform in order to calculate the result:-

/wp-content/uploads/2014/07/pic16_499163.jpg

first operation is calculate_total_marks which is BRFPLUS expression to perform the total and then we need to pass the result to the field Maximum_marks in the returning resultset:-

/wp-content/uploads/2014/07/pic17_499164.jpg

this is again the table operation SUM again very much similar to SELECT SUM() in SAP ABAP.

8. The next operation in the rule is to calculate the total marks secured by the student which is again a table operation as described in step7 but this time its on the input parameter actual marks:-

/wp-content/uploads/2014/07/pic18_499165.jpg

9. The next operation is to calculate the percentage which is done through by creating Formula in BRFPLUS which is highlighted in the screenshot given below:-

/wp-content/uploads/2014/07/pic19_499166.jpg

10.Lastly after calculating we need to send an intimation email saying that the result has been dispatched which is achieved through action in BRFPLUS:-

/wp-content/uploads/2014/07/pic20_499167.jpg

     the recipient you can put your personal email id.

11.     All the steps with respect to the creation of BRFPLUS is over just to test you need to go back to the function and click on simulate button as per screenshots given below:-

/wp-content/uploads/2014/07/pic21_499168.jpg

in the simulation screen enter the subjects and marks you can also select the radio button Show also results of Intermediate steps:-

/wp-content/uploads/2014/07/pic22_499172.jpg

/wp-content/uploads/2014/07/pic23_499173.jpg

Steps for preparing the business scenario in CRM BSP workbench

In the above section we have prepared the BRFPLUS scenario now we’ll be using the same in BSP workbench so that users can utilize it using user friendly interface. To achieve this we first need to you need to create RFC/Webservice for the BRFPLUS so that its easily reusable in any interface for doing this just click on the generate web service button and enter the web service name and other details:-

/wp-content/uploads/2014/07/pic24_499174.jpg

As I had specified this is a simple illustration and no BOL object is involved we’ll be using simple value node context node BSP application to showcase the BRFPlus functionality. For this:-

1.       Create a BSP application with name Z_STUD_RESULT using BSP workbench transaction BSP_WD_CMPWB.

2.      Create search View(table type View) with the context node as per the below screenshots:-

/wp-content/uploads/2014/07/pic25_499175.jpg

both of them should be binded to the either component controller/Custom controller so that while searching the data could retained. In the layout page add the following code:-

/wp-content/uploads/2014/07/pic26_499176.jpg

Here the variable gv_edit_mode is the string type global variable defined and the purpose of this variable is to change the mode to edit/display of the search table type view:-

/wp-content/uploads/2014/07/pic27_499177.jpg

After this in layout page (.HTM) add the buttons by including the BHTML code:-

/wp-content/uploads/2014/07/pic28_499181.jpg

1.       where 1 button “Get_result” is for calling the webservice to BRFPLUS and the other button is for entering the student marks. Now add the events for both these buttons(EH_ONADD_DATA and EH_ONGET_RESULT) the code snippet for both of them is given below:-

METHOD eh_onadd_data.

  TYPES: BEGIN OF ltype_attr_struct,

           maximum_marks TYPE int1,

           actual_marks TYPE int1,

           subject TYPE char70,

           END OF ltype_attr_struct.

  CONSTANTS: lc_edit_mode TYPE string VALUE ‘ALL’.

  DATA:    lv_struct_ref TYPE REF TO ltype_attr_struct,

           lv_value_node TYPE REF TO cl_bsp_wd_value_node,

           lv_bo_coll    TYPE REF TO if_bol_bo_col.

  gv_edit_mode = lc_edit_mode.

  lv_bo_coll ?= me->typed_context->studentmarks->collection_wrapper.

  CREATE DATA lv_struct_ref.

  CREATE OBJECT lv_value_node

    EXPORTING

      iv_data_ref = lv_struct_ref.

  lv_bo_coll->add( lv_value_node ).

  1. ENDMETHOD.

And

METHOD eh_onget_result.

  TYPES: BEGIN OF ltype_attr_struct,

             maximum_marks TYPE int1,

             actual_marks TYPE int1,

             subject TYPE char70,

         END OF ltype_attr_struct.

  TYPES: BEGIN OF ltype_attr_struct_1,

             total_marks TYPE int1,

             maximum_marks TYPE int1,

             percentage TYPE int1,

         END OF ltype_attr_struct_1.

  DATA: lv_bo_coll    TYPE REF TO if_bol_bo_col,

        lv_value_node TYPE REF TO cl_bsp_wd_value_node,

        lv_fin_resbrf TYPE zws_res007pktj2ivl1z3f4bsrwmdu,

        lv_final_result TYPE zstudent_final_result,

        lv_final_res    TYPE ltype_attr_struct_1,

        lv_data_marks TYPE ltype_attr_struct.

  DATA: lv_struct_ref_res TYPE REF TO ltype_attr_struct,

        lv_value_node_res TYPE REF TO cl_bsp_wd_value_node.

  DATA:  lt_input_res TYPE zws_res007pktj2ivl1z3f4bsrvkgi,

         ls_input_res TYPE zws_res007pktj2ivl1z3f4bsrvqs2.

  lv_bo_coll ?=  me->typed_context->studentmarks->collection_wrapper.

  IF lv_bo_coll IS BOUND AND lv_bo_coll->size( ) GT 0.

    lv_value_node ?= lv_bo_coll->get_first( ).

    WHILE lv_value_node IS BOUND.

      CALL METHOD lv_value_node->if_bol_bo_property_access~get_properties

        IMPORTING

          es_attributes = lv_data_marks.

      IF lv_data_marks IS NOT INITIAL.

        MOVE-CORRESPONDING lv_data_marks TO ls_input_res.

        APPEND ls_input_res TO lt_input_res.

      ENDIF.

      lv_value_node ?= lv_bo_coll->get_next( ).

    ENDWHILE.

    IF lt_input_res[] IS NOT INITIAL.

      CALL FUNCTION ‘ZFM_RESULT_CALC’

        EXPORTING

          data_input              = lt_input_res

        IMPORTING

          final_result            = lv_fin_resbrf

        EXCEPTIONS

          cx_fdt                  = 1

          cx_fdt_no_result        = 2

          cx_fdt_arithmetic_error = 3

          cx_fdt_processing       = 4

          OTHERS                  = 5.

      IF sy-subrc <> 0.

* Implement suitable error handling here

      ENDIF.

    ENDIF.

  ENDIF.

  IF lv_fin_resbrf IS NOT INITIAL.

    lv_final_result-total_marks = lv_fin_resbrf-total_marks.

    lv_final_result-maximum_marks = lv_fin_resbrf-maximum_marks.

    lv_final_result-percentage = lv_fin_resbrf-percentage.

  ENDIF.

  IF lv_final_result IS NOT INITIAL.

    MOVE-CORRESPONDING lv_final_result TO lv_final_res.

    lv_value_node ?= me->typed_context->studentresults->collection_wrapper->get_current( ).

    IF lv_value_node IS BOUND.

      CALL METHOD lv_value_node->if_bol_bo_property_access~set_properties

        EXPORTING

          is_attributes = lv_final_res.

    ENDIF.

  ENDIF.

  1. ENDMETHOD.

Create the result view and in that context node should be again binded to the component controller:-

/wp-content/uploads/2014/07/pic29_499182.jpg

Create the view set which will 1 column and 2 rows and it should contain both these views:-

/wp-content/uploads/2014/07/pic30_499183.jpg

Now the BSP page is ready for testing.

Testing the working model in browser

To test it just click on the test button of the BSP workbench

Click on enter exam data button and add the subjects with the marks and then click on get results

Here we have illustrated the usage of BRFPlus in SAP CRM workbench.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Keerthy Karunan
      Keerthy Karunan

      Hi Rajwin,

      Good doc for a person who wants to learn BRFPlus..Thanks for sharing...

      Also keep posting more docs..

      Author's profile photo Former Member
      Former Member

      Hi Rajwin,

      Very informative and detailed blog for creating a simple BRF Plus application..
      Thanks for sharind...Keep posting more blogs like this...

      Author's profile photo Himanshu Ashokkumar Sharma
      Himanshu Ashokkumar Sharma

      Hi Rajwin,

      Good document, Keep it up.

      Author's profile photo Former Member
      Former Member

      Very good blog for people who are begineer to BRFPLUS...Its really systemetic, step by step explanation...

      Author's profile photo Former Member
      Former Member

      Exceptionally good and very helpful.

      Thanks for sharing .

      Author's profile photo Mahesh Pusala
      Mahesh Pusala

      Good information. Thank you for sharing

      Author's profile photo Mohit Goel
      Mohit Goel

      Very detailed description of BRF+. Thanks for the wonderful document.

      Author's profile photo Abdul Kalam Akula
      Abdul Kalam Akula

      Thank you for wonderful Blog Rajwin..!!

      Author's profile photo Former Member
      Former Member

      Thank you for the detailed blog. This is helpful for the beginners of BRF Plus

      Author's profile photo Former Member
      Former Member

      Very nice explanation of BRFPlus scenario. It was delightful to watch. But I have one small doubt over here i.e. how actually we are integrating the BRFPlus application and the corresponding FM to get it work?

      May be I am missing something, please let me know.

      Thanks,

      Souvik

      Author's profile photo Rajwin Singh Sood
      Rajwin Singh Sood
      Blog Post Author

      Hi Sovik,

      If I am not wrong you are asking about the RFC FM which is actually calling the BRF function right? If yes we don't have to do the integration from the transaction BRF+ when the BRF function is activated and successfully testing automatically BRF+ transaction creates the RFC FM which has the code assoicated with it calling the BRF+ function. If you have created one you can check it for yourself by going into the function module using SE37