How to send Email to Manager
How do i send email to manager via workflow? i know this question has been asked so many times but i need more technical detail, here is what i have done so far:
1. Create workflow
2. Create function module for extracting the superior user id
My understanding so far is to create a rule that calling the function module, and use the rule in agent determination. But sending email does not need an agent so basicly how do i call the rule so the fm could be called and the binding is passing the value? Thanks
Suresh Subramanian replied
Hello Hendri Salim !
Create a background step which uses SWX_GET_MANAGER to find the manager.
Populate the manager name in workflow container of mail step.
Create job variant for the report RSWUWFML2, and in the job variant , configure the task id of the mail step.
Also maintain following settings in the job variant :
Select "Only New Workitems" check box.
Select "Workflow Entry " check box
Coding for SWX_GET_MANAGER to get SAP log on id of manager as follows : Change the coding as required to get e-mail id.
BEGIN_METHOD FINDMANAGER CHANGING CONTAINER. DATA: EXTENDEDOBJECTID TYPE OBJEC-REALO, addresstype like soxna-type, RECIPIENTADDRESS TYPE SOXNA-FULLNAME. DATA: ac_container like swcont occurs 0 with header line, addressstrings like soxna-fullname occurs 0 with header line. SWC_GET_ELEMENT CONTAINER 'ExtendedObjectID' addresstype = 'G'. ac_container-element = 'OBJID'. ac_container-tab_index = '000001'. ac_container-elemlength = '008'. ac_container-type = 'N'. ac_container-value = EXTENDEDOBJECTID. append ac_container. ac_container-element = 'OTYPE'. ac_container-tab_index = '000001'. ac_container-elemlength = '002'. ac_container-type = 'C'. ac_container-value = 'P '. append ac_container. CALL FUNCTION 'SWX_GET_MANAGER' TABLES ACTOR_TAB = addressstrings AC_CONTAINER = ac_container EXCEPTIONS NOBODY_FOUND = 01 OTHERS = 02. CASE SY-SUBRC. * WHEN 0. " OK * WHEN 01. " to be implemented WHEN OTHERS. " to be implemented ENDCASE. loop at addressstrings. if addressstrings(2) = 'P '. delete addressstrings. endif. endloop. move addressstrings to recipientaddress. SWC_SET_ELEMENT CONTAINER 'RecipientAddress' RECIPIENTADDRESS. END_METHOD.