Emails and notifications in SRM
Emails and notifications in SRM: The blog talks about different ways to create email and notifications from the systems. I have been using these methods for doing the changes and thought to include it in a blog .
Please read through these to understand on different options on how to handle the business requirement of sending notifications/emails . This is specifically related to the SRM space but some of these are also relevant to ECC area.I have also included the technical objects and code samples for a better understanding of how I have implemented them.
-
Changing text in the task
One of the easy ways is to modify the task directly . This also updates text in the UWL item sent to the recipient. Also if its sent as email it gets modified there as well . For doing so follow the below steps:
Find from SWIA as to what is the task ID for the particular scenario.
Now find the corresponding details for the task In the PFTC_CHG
I have used vendor number this is coming from Container. To understand the field name and what to write you should switch the technical View on
For Email content go to the tab description.Click on the pencil icon which opens up an editor.
if is_event-object_type = BUS2000113 and ( is_event-event = 'APPROVAL_PROCESS_DOC_APPROVED' or is_event-event = 'APPROVAL_PROCESS_DOC_REJECTED' ) and is_event-event_sub_categ = 'APPROVAL_RESULT_NOTIFIC_NEW' and is_event-event_categ = c_notification. call method custom_code_for_recipents ( exporting is_event = is_event changing ct_recipients = ct_recipients ).
If your requirement does not get met by using the standard config provided by SAP then use this BADI to read custom events and trigger notifications based on that . OR to change standard recipients etc.
The below link has a detailed documentation on this BADI.
https://wiki.scn.sap.com/wiki/display/SRM/BBP_ALERTING+-+Alerts,+Messages+and+Events+in+SRM+Alert+Management
- There is another method in this BADI which is IF_EX_BBP_ALERTING_BADI~BBP_EVENTS_DET_CLASS_NAME
This calls the standard class CL_BBP_MESSAGE_CREATE so you could replace the class by copying this class and then redefine the method DETERMINE_TEXT . It carries the details of what needs to be sent in the notification. See the sample code as below:
IF iv_object_type = BUS2201. IF is_event-event = 'WF_APPR_LATEST_START' OR is_event-event = 'WF_COMPL_LATEST_START' MOVE 'ZCL_BBP_MESSAGE_CREATE' TO cv_class_name. ENDIF. ENDIF.
Now in this Zclass I have changed the code for determine text to read text according to client’s requirement.
3 ALRTCATDEF : I am honestly not sure why SAP gave so many options for doing the same thing in multiple ways. So based on my understanding this one was probably for Functional people where they can configure alerts and edit the text and define priority etc based on how we just did using a BADI.
So here you can check for the SRM alerts section and in that I am using the BO as Purchase order in the right side.
Based on the specific criteria like a particular event or a specific value of ABAP field you can configure when the notification should be sent . The actual text to be sent goes in ‘Long and short text’ tab and also you could set priority for the message from the ‘properties’ tab.
Use report RSALERTTEST to test the approval alert configuration. Below document has good information around what needs to be included
https://archive.sap.com/kmuuid2/00e97ba2-85ce-2b10-20bc-bc05cd172154/Alert%20Configuration%20%E2%80%93%20Step%20by%20Step%20Guide.pdf
3. Another BADI which is often used in SRM to send notifications is BBP_OFFLINE_APP_BADI
This is used for sending notifications for the work items which are pending approval by the users.
This BADI is actually called in the standard SRM report /SAPSRM/OFFLINEAPPROVALSEND
And in this BADI you have methods which can be used to customize what gets sent to the user.
Method RECIPIENTS_GET to see if managers needs to be marked for a particular kind of email.
Method WORKITEMS_SELECT to select a specific task which was for buyers
Method MAIL_DATA_GET : Read your custom text in this method
Method MAIL_CREATE : lets you send attachment, Change subject, Body of the email
There is a parameter in MAIL_DATA_GET method called as is_sel_params-one4all = ‘X’ this sends one email per approver
“There are two types of sending of the mail: “One mail per workitem” and “One message for user”.
The code checks the variable s_opt-one4all, when it is set then the “One message for user” is used”
Read the below links for a detailed documentation on the BADI.
https://wiki.scn.sap.com/wiki/display/SRM/BBP_OFFLINE_APP_BADI+-+Changing+the+standard+offline+approval+process
https://wiki.scn.sap.com/wiki/display/SRM/Debugging+hints+for+sending+email+in+offline+approval
4. Modifying Attachments sent as SMARTFORMS.
BADI BBP_OUTPUT_CHANGE_SF is used to change the standard form names to your custom smarform with customer’s branding and logo.
This is called when a user clicks on a print/ Print preview button on the PO and the SC.
However you may call the implementation of this BADI if you plan to send attachments with your emails
The code for this BADI is something as below where I am forcing my smartform name based on some condition like object type and process type which is the document type
Also if you notice below I changed the format of the email from RAW to HTM
* find the alternative form SELECT SINGLE formname formname_mail INTO (lv_formname, lv_formname_email) FROM ztest WHERE custom_type = lv_process_type. IF lv_formname IS INITIAL. MOVE lv_formname TO cv_smartform. ENDIF. IF lv_formname_email IS NOT INITIAL. MOVE lv_formname_email TO cv_smartform_mail. MOVE 'HTM' TO cs_parameters-mail_format. ENDIF.
I hope I was able to throw some light (rather than confusing more) on different ways on how I have handled clients requirement to modify notifications and emails as per the business requirement.
Thanks for taking time to read my blog and please let me know if any queries / comments.
Regards
Vinita
New NetWeaver Information at SAP.com
Very Helpfull