Skip to Content

Implement Business Rules Logic in Custom Business Object

test
0 %
Implement Business Rules Logic in Custom Business Object
Details
// Explore More Tutorials

Implement Business Rules Logic in Custom Business Object

2019-05-15

Modify the business rules logic in custom business object to invoke the business rules for bonus percentage calculation of custom business object.

You will learn

  • How to extend custom business object to integrate business rules logic
  • Run the custom business object to see the change in the values based on business rules execution


Step 1: Open custom business object
  1. Open the Bonus Plan custom business object in S/4HANA cloud system.

  2. Switch to Logic tab.

  3. Click the After Modification link.

    modify custom business object
Can custom business object be extended with rules integration in SAP S/4HANA?
×
Step 2: Integrate rules logic in custom business object
  1. Copy this code appropriately after consistency check block.

    In the code do not forget to replace: bonusplanbusinessrules with your custom business object name and rule service ID in ABAP function call cl_fdt_brs_processor

    TYPES : BEGIN OF ts_bonus,
            percentage_value TYPE c LENGTH 3,
          END OF ts_bonus,
          tt_bonus TYPE TABLE OF ts_bonus.
    
    TYPES : BEGIN OF ts_bplan,
            high_bonus_assign_factor TYPE int4,
            low_bonus_assign_factor  TYPE int4,
            validity_end_date        TYPE d,
            validity_start_date      TYPE d,
          END OF ts_bplan.
    
    DATA : lr_data       TYPE REF TO data,
         lr_bonus      TYPE REF TO data,
         lt_name_value TYPE cl_fdt_brs_processor=>t_name_value,
         ls_name_value LIKE LINE OF lt_name_value,
         lt_data       TYPE tt_bonus,
         ls_input      TYPE ts_bplan.
    
    FIELD-SYMBOLS : <la_any>   TYPE ANY TABLE,
                  <lv_field> TYPE any,
                  <ls_bonus> TYPE data.
    
    DATA(lo_dsm) = cl_fdt_brs_processor=>get_instance( EXPORTING iv_function_id = '2ad0fa9edf294a0482235917f728cba9' ).
    
    lo_dsm->get_data_object_reference( EXPORTING iv_data_object = 'BONUS_PLAN_TT'
                                     IMPORTING er_data = lr_bonus ).
    
    ls_input-validity_start_date = bonusplanbusinessrules-validitystartdate.
    ls_input-validity_end_date = bonusplanbusinessrules-validityenddate.
    ls_input-low_bonus_assign_factor = bonusplanbusinessrules-lowbonusassignmentfactor.
    ls_name_value-name = 'BONUS_PLAN_TT'.
    ls_name_value-value = REF #( ls_input ).
    APPEND ls_name_value TO lt_name_value.
    
    "Invoke
    *TRY.
      lo_dsm->process( IMPORTING ea_result = lt_data
                       CHANGING  ct_name_value  = lt_name_value ).
    
    *ENDTRY.
    
    READ TABLE lt_data INTO DATA(ls_data) INDEX 1.
    bonusplanbusinessrules-lowbonuspercentage_v = ls_data-percentage_value.
    
    IF bonusplanbusinessrules-id IS INITIAL.
    bonusplanbusinessrules-isconsistent = abap_false.
    ENDIF.
    
  2. Click Publish to save and publish the changes.

    publish custom business object
Log on to answer question
Step 3: Test business rules logic
  1. Switch back to the General Information tab of custom business object.

  2. Click the Go To Generated UI link.

    run custom business object
  3. Click Go if you have bonus plan data created, or click + to create a new one.

    run custom business object

    You can edit the Low Bonus Assignment Factor and save it to see the change in Low Bonus Percentage

    run custom business object
Which ABAP (BRFPlus) utility API is used for rules consumption?
×

Next Steps

Prerequisites

  • S/4HANA Cloud system must be of release 1811 or higher.
  • Custom Business Object must already be created in S/4HANA Cloud.
  • Business rules must be created in SAP Cloud Platform and deployed in S/4HANA cloud.
Back to top