Sunteți pe pagina 1din 22

How To...

MDG-S: Dynamic Workflow Processing


based on changes to bank details
This Guide is also valid for MDG-C and MDG-BP (Data Model BP)

Applicable Releases:
MDG7.0 and Later

Version 1.0
Jan 2017
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

2
www.sap.com

Document History

Document Version Description

1.00 First official release of this guide


How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

TABLE OF CONTENTS
1. BUSINESS SCENARIO ........................................................................................................................................... 5
2. PREREQUISITES ................................................................................................................................................... 5
3. INTRODUCTION................................................................................................................................................... 5
3.1. STORY BOOK ................................................................................................................................................... 5
3.2. HIGH LEVEL STEPS ........................................................................................................................................... 5
4. STEP-BY-STEP EXPLANATION ............................................................................................................................... 6
4.1. CREATE NEW CHANGE REQUEST TYPE .......................................................................................................................... 6
4.2. IMPLEMENTATION OF BADI ....................................................................................................................................... 7
4.3. CREATE ABAP DICTIONARY OBJECTS .......................................................................................................................... 10
4.4. MODELING BRF+ ELEMENTS AND THE PROCESS FLOW IN BRF+ ...................................................................................... 11
4.5. IMPLEMENT ABAP CLASS ........................................................................................................................................ 17
4.6. TEST .................................................................................................................................................................... 20
5. REMARKS ...........................................................................................................................................................22

4
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

1. BUSINESS SCENARIO
SAP Master Data Governance for Supplier (MDG-S) provides business processes to find, create, change,
and mark supplier master data for deletion. It supports the governance of supplier master data on a central
hub and the distribution of supplier master data to connected operational and business intelligence systems.
The processes are workflow-driven and can include several approval and revision phases, including
collaboration between all users participating in master data maintenance. The workflows which are delivered
in MDG-S standard are classic workflows and do support most of the existing business use cases such as:
- Approval of global relevant attributes
- Parallel processing based on organizational units
- Final approval by organizational unit.
Sometimes the business requirements are different, and the classic workflow templates shipped by SAP do
not fit to the customer needs. Because of that, customers can also use the Rule-Based Workflow template
(RBW) which gives full flexibility for the workflow modeling. This is done by maintaining BRF+ decision
tables. SAP MDG delivers this RBW Template as standard and it can be used in MDG-S (and MDG-C). It is
integrated into the SAP MDG customizing (Shortcut: mdgimg).
Based on this template it is possible to have dynamic workflow routing based on values entered during
runtime by the user.
This How-To guide shows how to use these capabilities and how to implement such requirements. The
example scenario we are using is the following: An existing supplier can be changed using SAP MDG-S
without any approval. Only if the bank details have been changed an approver must review the changes
done by the requestor. The following graphic shows you the process flow in a simplified way.

With the Rule-Based Workflow (RBW) you can model all forms of rejections, parallel processing, and more
complex flows. These are not part of this How To guide.

2. PREREQUISITES
- Guide was written on a SAP MDG 9.0 environment but should work starting with SAP MDG 7.0
- ABAP development skills

3. INTRODUCTION
3.1. STORY BOOK
At a company, existing suppliers can be changed easily using MDG-S Change Requests without any
approvals. A review by an additional approver is only required if the Bank details are changed by a
requestor. Only if the approver is convinced that the newly entered bank details or changes are correct will
he approve the change. This prevents possible fraud.
3.2. HIGH LEVEL STEPS
The implementation consists of 6 steps:
1. Configure new MDG Change Request Type with the Rule-Based Workflow template. This step is done
in the Master Data Governance implementation guide (mdgimg).
2. Implementation of the BADI
3. Create ABAP dictionary objects
4. Modeling BRF+ elements and the process flow in BRF+

5
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

5. Implement ABAP class


6. Test

4. STEP-BY-STEP EXPLANATION
4.1. Create new Change Request Type
1. Go to transaction mdgimg and navigate to General Settings  Process Modeling  Change
Requests and execute activity Create Change Request Type

2. Choose New Entries and enter the following:


a. Type of Chg. Request: ZSUP_BAN
b. Data Model : BP
c. Description: “MDG-S: Dynamic Approval (Bank Demo)”
d. Select “Single Object”
e. Main Entity: BP_HEADER
f. Workflow: WS60800086
g. Choose Enter

3. Select the CR Type and choose Entity Types: Add new Entity Type: BP_Header

6
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

4. Add the Business Scenario: SUP2

a. Save all changes. Ignore the warning


5. Define Change Request Steps for Rule based Workflows
a. In the Master Data Governance implementation guide (mdgimg) go to General Settings 
Process Modeling  Workflow and execute activity Define Change Request Steps for Rule
based Workflows
b. Add 4 new Entries:

c. Save all changes. Ignore the warning


6. Define Service Name for Rule based Workflows
a. In the Master Data Governance implementation guide (mdgimg) go to General Settings 
Process Modeling  Workflow and execute activity “Define Service Names for Rule based
Workflows”
b. Add new Entry:
ZMDGS_RBW_CONTEXT_BANK Demo XY - Dyn. Context for MDGS RBW Context

c. Save all changes

4.2. Implementation of BAdI


1. In the Master Data Governance implementation guide (mdgimg) go to General Settings  Process
Modeling  Workflow  Rule-based Workflow  Business Add-Ins: Execute the activity BAdI: Rule
Context Preparation for Rule-Based Workflow

7
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

2. Choose New:

8
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

3. Enter “ZMDGS_RBW_DYN_CONTEXT” as Enhancement Implementation and description

4. Choose Ok and assign package


5. In the next screen enter
a. Badi Impl.: ZMDGS_RBW_DYN_CONTEXT_IMPL
b. Class: ZCL_MDGS_RBW_DYN_CONTEXT

6. In the next popup select “Copy sample class”: This is an example from MDG-M and we will change it
later.
7. In the BAdI: define Filter Val.

9
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

8. Save all and Activate all (will be done later again)

4.3. Create ABAP dictionary objects


1. Go to SE80 and create a new Domain: ZMDGS_BANK_CHANGED with CHAR 1

2. Define a Value Range:

10
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

3. Create a Data Element: ZMDGS_BANK_CHANGED

4. Activate both objects

4.4. Modeling BRF+ elements and the process flow in BRF+


1. In the Master Data Governance implementation guide (mdgimg) go to General Settings  Process
Modeling  Workflow  Rule-based Workflow: Execute activity Configure Rule-Based Workflow: a
popup appears and the BRF+ workbench opens with the right parameters.

11
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

2. Enter the newly created CR Type: ZSUPBAN and continue


3. Create new Data Object type “Element” called ZMDGS_BANK_CHANGED with DDIC reference to
ZMDGS_BANK_CHANGED

12
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

4. Activate the new element

5. Add element to function signature


Go to Trigger function and add the new element and Activate

13
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

6. Define the Service Name


Define the Service in the BRF+ application:

7. Setup the decision table


Now you can add the newly created data objects to the conditions for the workflow modeling
- Open table DT_SINGLE_VAL_ZSUPBAN
- Choose Edit
- Choose on Table Settings
- Define these settings:

14
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

8. Import the BRF+ examples


Now you can import the example

15
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

- Repeat this for all 3 tables

16
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

- Assign the right users or roles in the DT_USER_AGT_GRP_ZSUPBAN

Info:
- In Table DT_SINGLE_VAL_ZSUPBAN the first 2 lines are interesting: Dependent on the custom
condition the workflow is dynamically routed.

4.5. Implement ABAP class


Now you must implement the ABAP class with the corresponding functionality. The class was created
during the wizard usage in former step.

The example class in this How-To guide has the following methods:

- No class attributes defined


- No events attributes defined
- No types attributes defined
- The interfaces have been defined during the wizard based creation:

17
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

- Methods:
o IF_USMD_SSW_RULE_CNTX_PREPARE~PREPARE_RULE_CONTEXT: This is the
method which is called by the MDG framework and can have these lines:
DATA: lv_brf_expr_id TYPE if_fdt_types=>id.
DATA: ls_context TYPE usmd_s_fdt_context_value.
DATA: lv_crequest TYPE usmd_s_crequest.
FIELD-SYMBOLS: <value> TYPE any.
* Prepare export parameters
CLEAR et_message.
CLEAR et_rule_context_value.

" STEP 1: GET THE BRF+ ATTRIBUTE ID


CALL METHOD read_crequest EXPORTING iv_cr_number = iv_cr_number
IMPORTING es_crequest = lv_crequest.
* fill out the return table
get_element_id( EXPORTING iv_cr_type = lv_crequest-usmd_creq_type
iv_name = 'ZMDGS_BANK_CHANGED' IMPORTING ev_brf_expr_id =
lv_brf_expr_id ).
ls_context-id = lv_brf_expr_id.
CREATE DATA ls_context-value TYPE zmdgs_bank_changed.
ASSIGN ls_context-value->* TO <value>.

" STEP 2: RETRIEVE THE VALUE OF THE ATTRIBUTE


CALL METHOD zcl_mdgs_rbw_dyn_context=>is_bp_bkdtl_included
EXPORTING iv_cr_number = iv_cr_number IMPORTING ev_included =
<value> .
APPEND ls_context TO et_rule_context_value.

o GET_ELEMENT_ID: This method returns the ID of the element defined in the BRF+
application in former step
METHOD GET_ELEMENT_ID.
DATA:
lv_application_id TYPE if_fdt_types=>id,
lo_brf_factory TYPE REF TO if_fdt_factory,
lo_brf_query TYPE REF TO if_fdt_query,
lt_selection TYPE if_fdt_query=>ts_selection,
ls_selection LIKE LINE OF lt_selection,
ls_obj_category TYPE if_fdt_query=>s_object_category_sel,
lt_names TYPE if_fdt_query=>ts_name,
ls_names TYPE if_fdt_query=>s_name.

*-------------------------------------------------------------------
-*

ASSERT iv_cr_type IS NOT INITIAL.


ASSERT iv_name IS NOT INITIAL.

* get the ID of the brf+ application depending on the CR type


lv_application_id =
cl_usmd_wf_ssw_rule_service=>get_cr_type_app_id( iv_cr_type ).
IF lv_application_id IS INITIAL.
MESSAGE x000(usmd1). "no brf+ application exists for this cr

18
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

type
ENDIF.

lo_brf_factory = cl_fdt_factory=>if_fdt_factory~get_instance( ).

* create a query object instance ...


lo_brf_query = lo_brf_factory->get_query(
iv_object_type =
if_fdt_constants=>gc_object_type_data_object
iv_data_object_type =
if_fdt_constants=>gc_data_object_type_element ).

* ... and define the selection criteria


ls_selection-queryfield = if_fdt_admin_data_query=>gc_fn_name.
ls_selection-sign = 'I'.
ls_selection-option = 'EQ'.
ls_selection-low = iv_name.
INSERT ls_selection INTO TABLE lt_selection.

ls_selection-queryfield =
if_fdt_admin_data_query=>gc_fn_application_id.
ls_selection-sign = 'I'.
ls_selection-option = 'EQ'.
ls_selection-low = lv_application_id.
INSERT ls_selection INTO TABLE lt_selection.

ls_obj_category-system_objects = abap_true.
ls_obj_category-customizing_objects = abap_true.
ls_obj_category-masterdata_objects = abap_false.

* select the data


lo_brf_query->select_data(
EXPORTING
its_selection = lt_selection
is_object_category_sel = ls_obj_category
IMPORTING
eta_data = lt_names ).

READ TABLE lt_names INTO ls_names INDEX 1.


ev_brf_expr_id = ls_names-id.

ENDMETHOD.

o READ_CREQUEST – reads CR Header data (like CR Type)


method READ_CREQUEST.
DATA: lr_model TYPE REF TO if_usmd_model_ext.
DATA: lt_sel TYPE usmd_ts_sel.
DATA: ls_sel TYPE usmd_s_sel.
DATA: lt_crequest TYPE usmd_ts_crequest.
CONSTANTS: lc_incl TYPE ddsign VALUE 'I'.
CONSTANTS: lc_equal TYPE ddoption VALUE 'EQ'.

CLEAR: es_crequest.
* Get read-only access to USMD model data
CALL METHOD cl_usmd_model_ext=>get_instance
EXPORTING
i_usmd_model = if_mdg_bs_mat_gen_c=>gc_model_mm
IMPORTING
eo_instance = lr_model.
* Read the CR itself (to get the CR type)
ls_sel-sign = lc_incl.

19
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

ls_sel-option = lc_equal.
ls_sel-fieldname = usmd0_cs_fld-crequest.
ls_sel-low = iv_cr_number.
INSERT ls_sel INTO TABLE lt_sel.
CALL METHOD lr_model->read_char_value
EXPORTING
i_fieldname = usmd0_cs_fld-crequest
it_sel = lt_sel
if_use_edtn_slice = abap_false
IMPORTING
et_data = lt_crequest.
READ TABLE lt_crequest INTO es_crequest INDEX 1.
ASSERT sy-subrc = 0. " CR not found
endmethod.

o IS_BP_BKDTL_INCLUDED: This class returns if the MDG entity 'BP_BKDTL' was changed
within the CR. It uses another class to read the “staging” area content
METHOD is_bp_bkdtl_included.

DATA:
lt_all_staging TYPE usmd_ts_entity_data_all,
ls_all_staging TYPE usmd_sx_entity_data_all.

CALL METHOD zcl_mdgs_rbw_dyn_context=>read_data


EXPORTING
iv_crequest = iv_cr_number
iv_readmode = if_usmd_model_ext=>gc_readmode_no_act
IMPORTING
et_entity = lt_all_staging.

LOOP AT lt_all_staging INTO ls_all_staging.


IF ls_all_staging-usmd_entity_cont EQ 'BP_BKDTL'.
ev_included = 'X'.
RETURN.
ENDIF.
ENDLOOP.
ev_included = '-'.

ENDMETHOD.

o READ_DATA: This method can be implemented by you to read all entities in staging
typically you use readmode “gc_readmode_no_act” to get only inactive/staging data.
Please use the MDG-API to retrieve this data.

4.6. Test
Step by Step guide for testing
Test 1: Change of existing customer including bank details  Approval
Step 1: Requestor
- Login as requestor
- Go to MDG-S  Search
- Search for an existing Business Partner
- Select the record in the result list and click on EDIT
- Select CR Type MDG-S: Dynamic Approval (Bank Demo) from CR Type List

20
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

- Change the Address (or any other) attribute.


- Add (or change) bank details/ account number within the bank details

- Submit your request


- Remember the CR ID:_____________
- Logoff from the NWBC

Step 2: Approver
- Login as approver
- Go to MDG-S and page “My Change Requests”
- Review the list and you will see that the CR_ID from last step is in the list
- Open the MDG CR
- System informs you about changed Bank details by color highlighting
- Approve the CR

Test 2: Change of existing customer without changing bank details  auto approval
Step 1: Requestor
- Login as requestor
- Go to MDG-S  Search
- Search for existing Business Partner
- Select the record in the result list and click on change
- Select CR Type “MDG-S: Dynamic Approval (Bank Demo)” from CR Type List
- Change the Address (or any other) attribute.
- Do not change the bank details
- Submit your request
- Remember the CR ID:_____________
- Logoff from the NWBC

Step 2: Approver
- Login as approver

21
How To... MDG-S: Dynamic Workflow Processing based on changes to bank details

- Go to MDG-S and page My Change Requests


- Review the list and you will see that the CR_ID from last step is NOT in the list
- Go to page Display Change Requests and search for the CR_ID from last step
- You will identify that the CR is already approved without any approval.

5. REMARKS
- This guide can also be used for all other kinds of dynamic routing; it is not limited to bank details only
- Due to the fact that the BP data model is used you can also use it for MDG-C and MDG-BP related
processes
- A more general guide on the BAdI USMD_SSW_RULE_CONTEXT_PREPARE is located here:
https://archive.sap.com/documents/docs/DOC-14881
- The Code in this Guide, SAP Code or application samples and tutorials are NOT FOR PRODUCTIVE
USE. You may not demonstrate, test, examine, evaluate or otherwise use them in a live operating
environment or with data that has not been sufficiently backed up. You may not rent, lease, lend, or
resell SAP code or application samples and tutorials.

22

S-ar putea să vă placă și