

Utility for copying MDG BRF+ workflow Decision Tables
source link: https://blogs.sap.com/2023/02/15/utility-for-copying-mdg-brf-workflow-decision-tables/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Utility for copying MDG BRF+ workflow Decision Tables
If for any reason, you have a fairly detailed segmentation of BP types and activities in MDG, there’s a chance you have had to copy over BRF+ workflows.
Now, this is not a terribly difficult thing to do as the Import/Export functionality in BRF+ is a great feature. However minor changes can be a headache and I was getting tired of clicking the Import/Export button every time that happens.
Below is a little code I used to quickly copy over data the workflow BRF+ decision tables from one Change Request Workflow into another.
It’s obviously rough. The error management could be improved, but it’s good enough for occasional adjustment activity.
Helper Class
This is the local class I used as a helper.
CLASS lcl_brf DEFINITION.
PUBLIC SECTION.
METHODS get_reference_decision_tab
IMPORTING iv_crtype TYPE string
RAISING zcx_mdg.
METHODS get_decision_tab_object
IMPORTING iv_name TYPE string
RETURNING VALUE(ro_object) TYPE REF TO cl_fdt_decision_table
RAISING zcx_mdg.
METHODS get_decision_tab_data
IMPORTING iv_name TYPE string
RETURNING VALUE(rt_decision_tab) TYPE if_fdt_Decision_table=>ts_table_data
RAISING zcx_mdg.
METHODS copy_to
IMPORTING iv_crtype TYPE string
RAISING zcx_mdg.
METHODS copy_decision_table
IMPORTING iv_name TYPE string
it_decision_tab TYPE if_fdt_Decision_table=>ts_table_data
RAISING zcx_mdg.
METHODS constructor.
PRIVATE SECTION.
DATA mo_brf_query TYPE REF TO if_fdt_query.
DATA mo_brf_factory TYPE REF TO if_fdt_factory.
DATA mt_user_agent TYPE if_fdt_decision_table=>ts_table_data.
DATA mt_non_user_agent TYPE if_fdt_decision_table=>ts_table_data.
DATA mt_single_value TYPE if_fdt_decision_table=>ts_table_data.
ENDCLASS.
CLASS lcl_brf IMPLEMENTATION.
METHOD constructor.
mo_brf_factory ?= cl_fdt_factory=>if_fdt_factory~get_instance( ).
mo_brf_query ?= mo_brf_factory->get_query( ).
ENDMETHOD.
METHOD get_decision_tab_data.
DATA : o_decision_table TYPE REF TO cl_fdt_decision_table.
mo_brf_query->get_ids(
EXPORTING
iv_name = CONV #( iv_name )
iv_object_type = if_fdt_constants=>gc_object_type_expression
IMPORTING
ets_object_id = DATA(app_ids) ).
o_decision_table ?= mo_brf_factory->get_expression( app_ids[ 1 ] ) .
o_decision_table->if_fdt_decision_table~get_table_data( IMPORTING ets_data = rt_decision_tab ).
ENDMETHOD.
METHOD get_reference_decision_tab.
DATA : o_ref_decision_table TYPE REF TO cl_fdt_decision_table.
mt_user_agent = get_decision_tab_data( |DT_USER_AGT_GRP_{ iv_crtype }| ).
mt_non_user_agent = get_decision_tab_data( |DT_NON_USER_AGT_GRP_{ iv_crtype }| ).
mt_single_value = get_decision_tab_data( |DT_SINGLE_VAL_{ iv_crtype }| ).
ENDMETHOD.
METHOD get_decision_tab_object.
mo_brf_query->get_ids(
EXPORTING
iv_name = CONV #( iv_name )
iv_object_type = if_fdt_constants=>gc_object_type_expression
IMPORTING
ets_object_id = DATA(app_ids) ).
ro_object ?= mo_brf_factory->get_expression( app_ids[ 1 ] ) .
ENDMETHOD.
METHOD copy_decision_table.
DATA : o_decision_table TYPE REF TO cl_fdt_decision_table.
TRY.
o_decision_table = get_decision_tab_object( iv_name ).
o_decision_table->if_fdt_transaction~enqueue( ).
o_decision_table->if_fdt_decision_table~set_table_data( EXPORTING its_data = it_decision_tab ).
o_decision_table->if_fdt_transaction~activate(
EXPORTING iv_deep = abap_true
IMPORTING et_message = DATA(messages)
ev_activation_failed = DATA(lv_actv_failed) ).
if lv_actv_failed = abap_true.
MESSAGE e000(zmdg) WITH 'Error updating' iv_name INTO zcl_messages=>sv_message_text.
RAISE EXCEPTION TYPE zcx_mdg
EXPORTING
mo_messages = NEW zcl_messages( )->set_system_message( ).
endif.
o_decision_table->if_fdt_transaction~save( ).
o_decision_table->if_fdt_transaction~dequeue( ).
CATCH cx_fdt.
MESSAGE e000(zmdg) WITH 'Error updating' iv_name INTO zcl_messages=>sv_message_text.
RAISE EXCEPTION TYPE zcx_mdg
EXPORTING
mo_messages = NEW zcl_messages( )->set_system_message( ).
ENDTRY.
ENDMETHOD.
METHOD copy_to.
copy_decision_table( iv_name = |DT_USER_AGT_GRP_{ iv_crtype }|
it_decision_tab = mt_user_agent ).
copy_decision_table( iv_name = |DT_NON_USER_AGT_GRP_{ iv_crtype }|
it_decision_tab = mt_non_user_agent ).
copy_decision_table( iv_name = |DT_SINGLE_VAL_{ iv_crtype }|
it_decision_tab = mt_single_value ).
ENDMETHOD.
ENDCLASS.
Execution
Below is a sample code for using the class above.
START-OF-SELECTION.
TRY.
DATA(o_brf) = NEW lcl_brf( ).
o_brf->get_reference_decision_tab( 'ZCR1' ).
o_brf->copy_to( 'ZCR2' ).
o_brf->copy_to( 'ZCR3' ).
CATCH /gerp/cx_mdg INTO DATA(o_error).
o_error->mo_messages->show_as_log( ).
ENDTRY.
With that utility, I can update one workflow and then use the utility to copy to all the others.
This approach can be used in decision tables outside of MDG, but note that (1) the structure has to be the same and (2) you have to identify the application name is those situations as the Decision Table Name is not unique.
Recommend
-
10
Easing the access to the information you need…. Over the past few years, we received a lot of feedback from our customers and partners, most of them stating that they were very happy with the rich content about SAP Master Data Govern...
-
6
Andrei F. on Twitter: "@JumboShrimp787 I completely messed up those figures when copying the tablesDon’t miss what’s happeningPeople on Twitter are the first to know.
-
54
Deepak Rawat August 29, 2021 3 minute read ...
-
13
Srinivasa Rao Sesham September 6, 2021 2 minute read ...
-
74
Rahadian Dewantoro September 8, 2021 3 minute read ...
-
7
Kefeng Wang October 14, 2021 1 minute read
-
18
Anirban Roy December 23, 2021 1 minute read
-
18
Data Journey from SAP MDM to SAP MDG SAP NetWeaver MDM was a stand-alone system built on C/C++, which started its journey in 2005, when SAP acquired of a company named A2A. It has reached its End of Life in 2020. In 2022 t...
-
4
Search Questions and Answers
-
8
Search Questions and Answers
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK