Send a Mail Notification During the MDGF Process

24
SAP How-To Guide Master Data Governance for Financials How ToMaster Data Governance for Financials: Send a Mail notification during the governance process Applicable Releases: EhP5 Version 1.0 August 2011

Transcript of Send a Mail Notification During the MDGF Process

Page 1: Send a Mail Notification During the MDGF Process

SAP How-To Guide

Master Data Governance

for Financials

How To…

Master Data Governance for

Financials:

Send a Mail notification during the

governance process

Applicable Releases:

EhP5

Version 1.0

August 2011

Page 2: Send a Mail Notification During the MDGF Process

© Copyright 2011 SAP AG. All rights reserved.

No part of this publication may be reproduced or

transmitted in any form or for any purpose without the

express permission of SAP AG. The information contained

herein may be changed without prior notice.

Some software products marketed by SAP AG and its

distributors contain proprietary software components of

other software vendors.

Microsoft, Windows, Outlook, and PowerPoint are

registered trademarks of Microsoft Corporation.

IBM, DB2, DB2 Universal Database, OS/2, Parallel

Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390,

OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP,

Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix,

i5/OS, POWER, POWER5, OpenPower and PowerPC are

trademarks or registered trademarks of IBM Corporation.

Adobe, the Adobe logo, Acrobat, PostScript, and Reader

are either trademarks or registered trademarks of Adobe

Systems Incorporated in the United States and/or other

countries.

Oracle is a registered trademark of Oracle Corporation.

UNIX, X/Open, OSF/1, and Motif are registered

trademarks of the Open Group.

Citrix, ICA, Program Neighborhood, MetaFrame,

WinFrame, VideoFrame, and MultiWin are trademarks or

registered trademarks of Citrix Systems, Inc.

HTML, XML, XHTML and W3C are trademarks or

registered trademarks of W3C®, World Wide Web

Consortium, Massachusetts Institute of Technology.

Java is a registered trademark of Sun Microsystems, Inc.

JavaScript is a registered trademark of Sun Microsystems,

Inc., used under license for technology invented and

implemented by Netscape.

MaxDB is a trademark of MySQL AB, Sweden.

SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP

NetWeaver, and other SAP products and services

mentioned herein as well as their respective logos are

trademarks or registered trademarks of SAP AG in

Germany and in several other countries all over the world.

All other product and service names mentioned are the

trademarks of their respective companies. Data contained

in this document serves informational purposes only.

National product specifications may vary.

These materials are subject to change without notice.

These materials are provided by SAP AG and its affiliated

companies ("SAP Group") for informational purposes only,

without representation or warranty of any kind, and SAP

Group shall not be liable for errors or omissions with

respect to the materials. The only warranties for SAP

Group products and services are those that are set forth in

the express warranty statements accompanying such

products and services, if any. Nothing herein should be

construed as constituting an additional warranty.

These materials are provided “as is” without a warranty of

any kind, either express or implied, including but not

limited to, the implied warranties of merchantability,

fitness for a particular purpose, or non-infringement.

SAP shall not be liable for damages of any kind including

without limitation direct, special, indirect, or consequential

damages that may result from the use of these materials.

SAP does not warrant the accuracy or completeness of the

information, text, graphics, links or other items contained

within these materials. SAP has no control over the

information that you may access through the use of hot

links contained in these materials and does not endorse

your use of third party web pages nor provide any warranty

whatsoever relating to third party web pages.

SAP NetWeaver “How-to” Guides are intended to simplify

the product implementation. While specific product

features and procedures typically are explained in a

practical business context, it is not implied that those

features and procedures are the only approach in solving a

specific business problem using SAP NetWeaver. Should

you wish to receive additional information, clarification or

support, please refer to SAP Consulting.

Any software coding and/or code lines / strings (“Code”)

included in this documentation are only examples and are

not intended to be used in a productive system

environment. The Code is only intended better explain and

visualize the syntax and phrasing rules of certain coding.

SAP does not warrant the correctness and completeness of

the Code given herein, and SAP shall not be liable for

errors or damages caused by the usage of the Code, except

if such damages were caused by SAP intentionally or

grossly negligent.

Disclaimer

Some components of this product are based on Java™. Any

code change in these components may cause unpredictable

and severe malfunctions and is therefore expressively

prohibited, as is any decompilation of these components.

Any Java™ Source Code delivered with this product is only

to be used by SAP’s Support Services and may not be

modified or altered in any way.

Page 3: Send a Mail Notification During the MDGF Process

Document History

Document Version Description

1.00 First official release of this guide

Page 4: Send a Mail Notification During the MDGF Process

Typographic Conventions

Type Style Description

Example Text Words or characters quoted

from the screen. These

include field names, screen

titles, pushbuttons labels,

menu names, menu paths,

and menu options.

Cross-references to other

documentation

Example text Emphasized words or

phrases in body text, graphic

titles, and table titles

Example text File and directory names and

their paths, messages,

names of variables and

parameters, source text, and

names of installation,

upgrade and database tools.

Example text User entry texts. These are

words or characters that you

enter in the system exactly as

they appear in the

documentation.

<Example

text>

Variable user entry. Angle

brackets indicate that you

replace these words and

characters with appropriate

entries to make entries in the

system.

EXAMPLE TEXT Keys on the keyboard, for

example, F2 or ENTER.

Icons

Icon Description

Caution

Note or Important

Example

Recommendation or Tip

Page 5: Send a Mail Notification During the MDGF Process

Table of Contents

1. Business Scenario............................................................................................................... 1

2. Background Information ..................................................................................................... 1

3. Step-by-Step Procedure ...................................................................................................... 2

3.1 Create a New Workflow ................................................................................................ 2

3.2 Modify the Workflow Container ..................................................................................... 4

3.3 Modify Activation Step .................................................................................................. 7

3.4 Add a Mail Notification Step ....................................................................................... 11

3.5 Configuration .............................................................................................................. 13

3.6 Example Coding for Program-Exit Class .................................................................... 14

Page 6: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 1

1. Business Scenario

SAP Master Data Governance for Financials (MDGF) provides business processes to find, create,

change and delete financial master data. It supports the governance of financial master data in a

centeral hub and the distribution to connected operational and business intelligence systems.

Master data in MDGF is maintained by change request. The processes of MDGF are business

workflow-driven and can include several approval and revision phases, and the collaboration of all

users participating in the master data maintenance.

This scenario addresses when a change request is finally approved, all users affected will get an

Email with a protocol of the change request. The Email contains change request metadata as well as

the data that has been maintained during processing of the change request.

This How To Guide describes possible solution to send out Email notification from the workflow.

2. Background Information

A new workflow step is added into the workflow template. You may adjust at which point the sending

mail step can be inserted as long as you have maintained the elements in workflow container.

Page 7: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 2

3. Step-by-Step Procedure

The following is a description of how to send an Email notification after activating a change request.

The scenario takes workflow WS75700040 as an example. The workflow WS75700040 only contains

three dialog steps.

The idea is that add a program-exit to the activation step of workflow. After the activation step add a

new step with type “Send Email”.

Example is developed in QV5/Client 005, tested in QV5/Client 405.

3.1 Create a New Workflow ...

1. At cross client, enter transaction SWDB. Fill workflow “WS75700040” and press ENTER

2. Select Workflow in menu and select “Save as…”

Page 8: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 3

3. In the prompted window, fill in abbreviation and name. Click

4. A new workflow number is generated automatically. Activate the workflow.

Page 9: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 4

3.2 Modify the Workflow Container ...

1. Create a new structure and new table type in the DDIC using transaction SE11. This will handle

the assigned object list of the change request.

a. Create a data type “Structure”

b. Create a data type “Table Type”

Page 10: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 5

2. Go to transaction SWDD, input the workflow that just created automatically. Select “Workflow

Container” at the left side.

3. Use the context menu to create two new container elements

Page 11: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 6

a. EMAILRECEIVER

This element is used to store users that need to be notified by Email. It’s of type

SWHACTOR. The properties are shown as below.

b. CREQUEST_OBJLST

This element is used to store master data in change request.

Page 12: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 7

3.3 Modify Activation Step ...

1. In transaction SWDD, select step “000298 Änderungen aktivieren” in Navigation area.

Page 13: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 8

2. At right panel, choose the option “Copy and Edit Task” from the dropdown list of Task ID.

3. Fill in all fields like following.

Note: There may be errors in setting work item text here. You may set the work item text after

binding.

Page 14: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 9

4. In tab Container, create two new container elements CREQUEST_OBJLST and

EMAILRECEIVER. Set the data type and properties just like before. Save the task and go back

to the step definition.

5. Binding the workflow container element with task container element.

Page 15: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 10

6. Create a new class using transaction SE24, which inherits interface

IF_SWF_IFS_WORKITEM_EXIT. Implement the method IF_SWF_IFS_WORKITEM_EXIT-

>EVENT_RAISED to set the container element EMAILRECEIVER and CREQUEST_OBJLST.

The example class ZCL_WORKFLOW_EXIT is added at bottom.

7. In step activation, go to tab Program Exits and add class ZCL_WORKFLOW_EXIT. The

example code of the class can be found in 3.6 Example Coding for Program-Exit Class

8. Save the workflow and click at the top of the activity.

Page 16: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 11

3.4 Add a Mail Notification Step

1. At left area of workflow builder, select „Step Types That Can Be Inserted“, and then move the

„Send Mail“ and drop down after the activation step.

Page 17: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 12

2. Fill in information to the step. You may insert element via icon „Insert Expression“.

3. Click tab Control and create a new task.

4. Double click the new task and create a new element CREQUEST_OBJLST in the container jsut

like steps before. If you run into locking issues, maintain the standard task using transaction

PFTS.

5. Binding between workflow container element and task container element. (Availability of the

parameters SIGN & ENCRYPT depend on the setup of the workflow and might not be

available. )

Page 18: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 13

6. Save the workflow and click at the top of the activity.

7. Activate the whole workflow.

3.5 Configuration

1. At MDG client, go to transaction MDGIMG. Go to node General Settings->Process Modeling-

>Workflow->Other MDG Workflows->Define Workflow Step Numbers. Add three steps for the

new created workflow.

2. Create a change request type with the new created workflow. The change request type can be

created at MDGIMG->General Settings->Process Modeling->Change Requests->Create

Change Request Type

3. Assign agents in MDGIMG->General Settings->Process Modeling->Workflow->Other MDG

Workflows->Assign processor to Workflow Step Number (Simple Workflow)

4. To make users in SAP system can receive and email, following settings are needed.

a. Add the email address in SU01 (or make sure it’s there)

b. Set „Comm. Method“ to „E-mail“ in SU01

c. In SO16, tab Mail sy.grp, radio button „Send to Home Addresses of Users“

d. In SO16, tab Addressing, Reset buffer

Page 19: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 14

3.6 Example Coding for Program-Exit Class

Example Coding:

METHOD if_swf_ifs_workitem_exit~event_raised. DATA: lo_workitem TYPE REF TO if_swf_ifs_parameter_container,

lt_objlst TYPE usmd_ts_crequest_objkey, lv_return TYPE sysubrc, ls_swotobjid TYPE swotobjid, lv_crequest TYPE usmd_crequest, lv_edition TYPE usmd_edition, lv_edtn_type TYPE usmd_edition_type, lv_model TYPE usmd_model, lo_model TYPE REF TO if_usmd_model, lt_message TYPE usmd_t_message, lt_message1 TYPE usmd_t_message, lt_objlst_ele TYPE zusmd_t_entity, lr_data TYPE REF TO data, ls_objlst TYPE usmd_s_crequest_objkey, ls_objlst_ele TYPE zusmd_s_entity, lv_obj TYPE string, ls_entity_prop TYPE usmd_s_entity_prop, ls_fdep TYPE usmd_s_fdep, ld_entity TYPE usmd_entity, lv_entity_txt TYPE usmd_value, lv_field_txt TYPE usmd_value, ls_receiver TYPE swhactor, lt_receiver_temp TYPE tswhactor, lt_receiver TYPE tswhactor, lr_badi_wf_agent TYPE REF TO usmd_wf_agent, ld_agent_filter TYPE swcont-value, lo_table TYPE REF TO cl_abap_tabledescr, lo_struct TYPE REF TO cl_abap_structdescr, lo_line TYPE REF TO cl_abap_datadescr,

Page 20: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 15

ls_comp TYPE abap_compdescr, lo_type TYPE REF TO cl_abap_typedescr.

FIELD-SYMBOLS: <f_obj> TYPE any, <f_value> TYPE any, <f_struct> TYPE any, <f_obj_tab> TYPE ANY TABLE.

* The email is sent only after the activation of master data CHECK im_event_name EQ if_swf_ifs_workitem_exit=>c_evttyp_after_execution.

*Get instance of workflow item lo_workitem = im_workitem_context->get_wi_container( ).

* Get Change request number TRY. CALL METHOD lo_workitem->get EXPORTING name = '_WI_OBJECT_ID' IMPORTING value = ls_swotobjid. lv_crequest = ls_swotobjid-objkey+0(12). CATCH cx_swf_cnt_elem_not_found . CATCH cx_swf_cnt_elem_type_conflict . CATCH cx_swf_cnt_unit_type_conflict . CATCH cx_swf_cnt_container . ENDTRY.

* Get object list of the change request * Get data model SELECT SINGLE usmd_edition FROM usmd120c INTO lv_edition WHERE usmd_crequest = lv_crequest. IF sy-subrc EQ 0. SELECT SINGLE usmd_edtn_type FROM usmd020c INTO lv_edtn_type WHERE usmd_edition = lv_edition. IF sy-subrc EQ 0. SELECT SINGLE usmd_model FROM usmd010c INTO lv_model WHERE usmd_edtn_type = lv_edtn_type. ENDIF. ENDIF.

IF lv_model IS NOT INITIAL. CALL METHOD cl_usmd_model=>get_instance EXPORTING i_usmd_model = lv_model IMPORTING eo_instance = lo_model et_message = lt_message.

Page 21: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 16

ENDIF.

IF lt_message IS INITIAL. CALL METHOD lo_model->if_usmd_model_crequest~crequest_get_objlist EXPORTING i_crequest = lv_crequest IMPORTING ets_crequest_objkey = lt_objlst et_message = lt_message1. ENDIF. APPEND LINES OF lt_message1 TO lt_message.

LOOP AT lt_objlst INTO ls_objlst. CLEAR ls_objlst_ele. ls_objlst_ele-entity = ls_objlst-fieldname. ASSIGN ls_objlst-r_data->* TO <f_obj>. lo_type = cl_abap_typedescr=>describe_by_data( <f_obj> ). CHECK lo_type->kind = cl_abap_typedescr=>kind_table. lo_table ?= lo_type.

lo_line = lo_table->get_table_line_type( ). ASSIGN <f_obj> TO <f_obj_tab>. IF lo_line->kind = cl_abap_typedescr=>kind_struct. lo_struct ?= lo_line.

IF lo_line->kind = cl_abap_typedescr=>kind_struct. lo_struct ?= lo_line.

IF <f_obj_tab> IS ASSIGNED. LOOP AT <f_obj_tab> ASSIGNING <f_struct>. CLEAR: lv_obj,ld_entity. * Get text of entity type CALL METHOD cl_usmd_services=>fieldname2entity EXPORTING io_model = lo_model i_fieldname = ls_objlst-fieldname RECEIVING

r_entity = ld_entity.

CALL METHOD cl_usmd_services=>entity2text EXPORTING io_model = lo_model i_entity = ld_entity RECEIVING

r_text = lv_entity_txt. CONCATENATE lv_entity_txt ':' INTO lv_obj SEPARATED BY space.

* Get master key of ld_entity READ TABLE lo_model->dt_entity_prop INTO ls_entity_prop WITH KEY usmd_entity = ld_entity.

Page 22: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 17

LOOP AT lo_model->dt_fdep INTO ls_fdep WHERE fieldname EQ ls_entity_prop-r_fprop->fieldname. IF sy-subrc EQ 0. ASSIGN COMPONENT ls_fdep-masterfield OF STRUCTURE <f_struct> TO <f_value>. ASSERT <f_value> IS ASSIGNED. ENDIF. * Get text of field name CALL METHOD cl_usmd_services=>fieldname2text EXPORTING io_model = lo_model i_fieldname = ls_fdep-masterfield RECEIVING

r_value = lv_field_txt. CONCATENATE lv_obj lv_field_txt ' ' <f_value> ' ' INTO lv_obj SEPARATED BY space . ENDLOOP. ls_objlst_ele-value = lv_obj. APPEND ls_objlst_ele TO lt_objlst_ele. ENDLOOP. ENDIF. ENDIF. ENDIF. ENDLOOP. TRY. CALL METHOD lo_workitem->set EXPORTING name = 'CREQUEST_OBJLST' value = lt_objlst_ele. CATCH cx_swf_cnt_elem_not_found . CATCH cx_swf_cnt_elem_type_conflict . CATCH cx_swf_cnt_unit_type_conflict . CATCH cx_swf_cnt_container . ENDTRY. ***************************************************************** *Set parameter EMAILRECEIVER ** Call BAdI to get agents IF ld_agent_filter IS INITIAL. ld_agent_filter = if_usmd_wf_agent=>gc_filter-standard. ENDIF.

GET BADI lr_badi_wf_agent FILTERS

agent_filter = ld_agent_filter. IF lr_badi_wf_agent IS BOUND. CALL BADI lr_badi_wf_agent->get_agents EXPORTING

Page 23: Send a Mail Notification During the MDGF Process

Send a Mail Notification During the MDGF Process

September 2011 18

id_appstep = '1' id_crequest = lv_crequest if_single_proc = '' id_index = 0 IMPORTING et_agent = lt_receiver_temp et_message = lt_message. ENDIF. APPEND LINES OF lt_receiver_temp TO lt_receiver. IF lr_badi_wf_agent IS BOUND. CALL BADI lr_badi_wf_agent->get_agents EXPORTING id_appstep = '2' id_crequest = lv_crequest if_single_proc = '' id_index = 0 IMPORTING et_agent = lt_receiver_temp et_message = lt_message. ENDIF. APPEND LINES OF lt_receiver_temp TO lt_receiver. IF lr_badi_wf_agent IS BOUND. CALL BADI lr_badi_wf_agent->get_agents EXPORTING id_appstep = '3' id_crequest = lv_crequest if_single_proc = '' id_index = 0 IMPORTING et_agent = lt_receiver_temp et_message = lt_message. ENDIF. APPEND LINES OF lt_receiver_temp TO lt_receiver.

TRY. CALL METHOD lo_workitem->set EXPORTING name = 'EMAILRECEIVER' value = lt_receiver. CATCH cx_swf_cnt_elem_not_found . CATCH cx_swf_cnt_elem_type_conflict . CATCH cx_swf_cnt_unit_type_conflict . CATCH cx_swf_cnt_container . ENDTRY.

IF lv_return IS INITIAL. ENDIF. ENDMETHOD.

Page 24: Send a Mail Notification During the MDGF Process

www.sdn.sap.com/irj/sdn/howtoguides