Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Rajwin 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.

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:-

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:-

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:-

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

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.

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

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

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

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:-

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:-

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:-

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:-

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:-

     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:-

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

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:-

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:-

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:-

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:-

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

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:-

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

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.

11 Comments
Labels in this area