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: 
former_member197134
Discoverer
Scenario:  Business analysts or few users don't have access to workbench to analyse the business data, So will get the Decision table data from BRF+ to Database table and displayed in a report/PDF.

Similarly for the scenario like any changes done in the Decision table data  by the users needs to save in the DB table.i.e who have made the changes for further reference by doing small changes in code.

 

In this Blog we are going discuss about how to create BRF+ Application, creation of Decision table, Creation of application exit class and binding the application class exit to BRF+ Application.

 

Read Decision table data into custom Database table while activating the DT(Decision Table ) at BRF+ Workbench.



 

Pre-requisites : Basic Knowledge on BRF+ Work bench , O ABAP.

 

Steps to creation of BRF+ Application and Decision table.

Step 1 : Create BRF+ Application.

 

Transaction  Code for  BRF work bench is BRF+ or BRFPLUS. 

The following screen will be open , where we can perform BRF+ Rules.



 

 

Create Application: Workbench ->Create Application as shown below.



 

Provide Application name and press Create and navigate to Object Button.

 



 

In General TAB Make sure to notedown  the GUID of Application. Which needs to provide while calling the BRF+ Application at application exit class.

 



 

Step 2 : Creation of decision table

Right Click on BRF+ Application, choose create, then choose expression and then choose Decision table.

Create->Expression->Decision table.



 

Provide Decision table  name and press Create and navigate to Object Button.

 



 

In General TAB Make sure to notedown the GUID of Decision Table. Which needs to provide while calling the reading Decision table data at application exit class.

 



 

Provide List of Conditional and result columns using Table Settings Button.

 



 

 

Creation of Application class exit:

Step 1 : Create Class using T-Code : SE24



Step 2: Provide interface as IF_FDT_APPLICATION_SETTINGS

 



 

Step 3: Following are the methods which are provided by the interface, we need to implement the methods as per the requirement, in this scenario we are going to implement Activation veto method.


To implement the Activation method we need to define Class Constructor



 
Implement the logic . I.e pass the TRUE value to the gv_activation_vento attribute(for activation). Similarly if we want to work with other scenarios like save , check etc , pass true for those attributes in the constructor.



 



Step 4: Implement the logic in IF_FDT_APPLICATION_SETTINGS~ACTIVATION_VETO method.

 



Paste the below logic to update the DB table from Decision table.

 
METHOD if_fdt_application_settings~activation_veto.

*the application guid

CONSTANTS: gc_appl_id TYPE if_fdt_types=>id VALUE '000C2986A9971EE780E0B4AB55C73047'.

*create a structure as per the Decision table

TYPES:BEGIN OF ts_msg_txt_data,

age TYPE char24,

gender TYPE char24,

pension TYPE char50,

END OF ts_msg_txt_data,

*Create a structure for the row count

BEGIN OF ts_table_data,

row_no TYPE int4,

col_no TYPE int4,

expression_id TYPE if_fdt_types=>id,

r_value TYPE REF TO data,

ts_range TYPE if_fdt_range=>ts_range,

END OF ts_table_data .

* data declarations

DATA: lref_decision_table TYPE REF TO cl_fdt_decision_table,

lref_factory TYPE REF TO if_fdt_factory,

lt_msg_data TYPE if_fdt_decision_table=>ts_table_data,

ls_msg_data LIKE LINE OF lt_msg_data,

lt_table_data_msg TYPE TABLE OF ts_table_data,

ls_table_data_msg TYPE ts_table_data,

ls_table_data1 TYPE ts_table_data,

lt_msg_txt_data TYPE STANDARD TABLE OF ts_msg_txt_data,

ls_msg_txt_data TYPE ts_msg_txt_data,

ls_range_msg TYPE if_fdt_range=>s_range,

lt_data_final TYPE TABLE OF ztest_data_2,
ls_data_final TYPE ztest_data_2.

*field symbols declaration

FIELD-SYMBOLS :<fs_lv_value> TYPE any,

<fs_lpw_lv_amount> TYPE if_fdt_types=>element_amount.

*Generic factory instance

lref_factory = cl_fdt_factory=>if_fdt_factory~get_instance( gc_appl_id ).

*get the expression the decision table guid

lref_decision_table ?= lref_factory->get_expression(

iv_id = '000C2986A9971EE780E0B8EDBC32904A' ).

*to get the decision table data based on above expression guid

lref_decision_table->if_fdt_decision_table~get_table_data(

IMPORTING

ets_data = lt_msg_data

).

IF lt_msg_data IS NOT INITIAL.

CLEAR lt_table_data_msg.

* Processing decision table and filling the ls_table_data_msg

LOOP AT lt_msg_data INTO ls_msg_data.

ls_table_data_msg-row_no = ls_msg_data-row_no.

ls_table_data_msg-col_no = ls_msg_data-col_no.

ls_table_data_msg-expression_id = ls_msg_data-expression_id.

ls_table_data_msg-r_value = ls_msg_data-r_value.

ls_table_data_msg-ts_range = ls_msg_data-ts_range.

APPEND ls_table_data_msg TO lt_table_data_msg.

CLEAR ls_table_data_msg.

ENDLOOP.

SORT lt_table_data_msg BY row_no col_no.

* Processing the loop lt_table_data_msg to fill structure as per the decision table

LOOP AT lt_table_data_msg INTO ls_table_data_msg.

ls_table_data1 = ls_table_data_msg.

CASE ls_table_data1-col_no.

* Age

WHEN 1.

IF ls_table_data1-ts_range IS NOT INITIAL.

READ TABLE ls_table_data1-ts_range INTO ls_range_msg INDEX 1.

IF sy-subrc = 0.

ASSIGN ls_range_msg-r_low_value->* TO <fs_lv_value>.

ls_msg_txt_data-age = <fs_lv_value>.

ENDIF.

ENDIF.

* Gender

WHEN 2.

IF ls_table_data1-ts_range IS NOT INITIAL.

READ TABLE ls_table_data1-ts_range INTO ls_range_msg INDEX 1.

IF sy-subrc = 0.

ASSIGN ls_range_msg-r_low_value->* TO <fs_lv_value>.

ls_msg_txt_data-gender = <fs_lv_value>.

ENDIF.

ENDIF.

* PENSION

WHEN 3.

IF ls_table_data1-r_value IS NOT INITIAL.

ASSIGN ls_table_data1-r_value->* TO <fs_lv_value>.

ls_msg_txt_data-pension = <fs_lv_value> .

ENDIF.

ENDCASE.

AT END OF row_no .

APPEND ls_msg_txt_data TO lt_msg_txt_data.

CLEAR ls_msg_txt_data.

ENDAT.

ENDLOOP.

ENDIF.

IF lt_msg_txt_data IS NOT INITIAL.
* Delete all records
DELETE FROM ztest_data_2.

MOVE-CORRESPONDING lt_msg_txt_data TO lt_data_final.
* Modify DB Table
MODIFY ztest_data_2 FROM TABLE lt_data_final.

COMMIT WORK.
ELSE.

DELETE FROM ztest_data_2.
ENDIF.

ENDMETHOD.

 

NOTE : Replace the GUID's in the logic as per your application GUID and Decision table GUID.

 

Biding BRF+ Application with Application exit class  and execution : 

Step 1 : Bind the class to application at  BRF+ workbench. as shown below.



 

Step 2 : Insert new row and provide the relevant  data in conditional columns and resultant columns.

 



 

Step 3: Activate Decision table at BRF+ work bench.



Step 4: Observe the result at DB table .

2 Comments
Labels in this area