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
Now i see that the field Vendor No which I need is coming from WI_OBJECT_ID >> VENDOR >> VendorNo can be seen in the incoming structure.
This I have now added to both my subject which is in basic data
For Email content go to the tab description.Click on the pencil icon which opens up an editor.
Now click on Add symbol option and enter the variable you would like to see in the email.
After doing the changes in the task don’t forget to refresh the buffer using Tcode SWU_OBUF.
This would now change/ create email notifications specific to the task.
2. Using BBP_ALERTING BADI
It checks the events you have configured in the config as below
IMG: Supplier Relationship Management -> SRM Server -> Cross-Application Basic Settings -> Event and Event Schema for Alert Management → Define Events
Here I am checking for events related to contract
I can see events like 'APPROVAL_PROCESS_DOC_APPROVED' and 'APPROVAL_PROCESS_DOC_REJECTED'
In method method if_ex_bbp_alerting_badi~bbp_events_det_recipients based on running these standard events you could add your own logic to determine recipients.
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.
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.
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.
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