Abstract

The document explains in detail the customization of an email notification triggered based on the threshold values applied to the business process monitoring object in the context of SAP Solution Manager. A simple code is explained to customize the Email with effective details in the context of Business Process Monitoring.

1.     Introduction

Business Process Monitoring (BPMon) functionality  of SAP Solution Manager provides the proactive and process-oriented monitoring of business processes.  Business Process Monitoring is intended to help you respond to potentially critical situations as early as possible. Hence, Business Process Monitoring offers various options of auto-notification for sending messages to the person responsible for certain alerts, includes notification message through email or SMS and creating a solution manger incident (optional). The standard email alert notification contains basic information about the alert (Solution name, Business process, process step, monitoring object name, etc.) and alert message text (contains key figure information, measured value and alert creation time, monitoring activities). To enrich email notification with additional information, there is a need for customization supported by SAP Standard BADI available into SAP SolMan Monitoring Framework.

2.     Objective

The main objective of this document is to  illustrate  customization of auto email notification by retrieving additional information of a key figure and provide a link to the Alert inbox in the email body. The BPMon framework offers a BADI exit that enables to adjust the auto-reaction messages according to the customer’s requirements, as well as to execute an additional customer-defined auto-reactions or even to create own-defined messages from scratch. Here goal is to improve the email structure with better email content and additional information that will provide more value on the alert information to the person responsilble.

3.     Prerequisites

Following are the prerequisites to use the enhanced possibilities for setting up auto-reactions, and BPMon BADIs.

Ø Basic knowledge of ABAP programming.

Ø Prerequisites for Business Process Monitoring as described in SAP note 784752. In particular, the sending of notification messages via SAPConnect (transaction SCOT).

Ø Understanding of Business Process Monitoring in SAP Solution Manager.

Ø At least one business process monitor has to be configured in Business Process Monitoring setup in SAP Solution Manager.

Ø Installation of ST-SER 700_2010_1, ST71 (SP05) or higher in the SAP Solution Manager system.

Additional information related to Business Process Monitoring in SAP Solution Manager can be found in SAP Service Marketplace http://service.sap.com/bpm.

4.    Standard email notification and its limitations

figure 1.jpg

         Figure 1. Standard alert email notification.

The standard alert notification in BPMon contains basical information about the alert (like the business process, the business process step, and the SID of the system that is affected) and the alert message text itself, which contains among others the key figure information, the timestamp of the alert, and the measured value.

However, for some customers this information is not sufficient enough. Either they want to determine the subject line of a certain alert in a more sophisticated way depending on the criticality of the alert or providing the three level hierarchy in the email body as defined in Solution Documentation under transaction code SOLAR01. Additionally, they want to include business context-specific information for e.g. adding the document numbers of the erroneous application documents in the long text of the message or remove the solution number and monitoring ID as the solution name and monitoring object name are sufficient. For such cases the BPMon framework offers a BADI exit that enables you to enrich the standard alert messages with customer-specific information or even to create custom defined messages from scratch.

5.     Setting up Notifications

BPMon provides an infrastructure of auto alert notification to the responsible person or a distribution list for any process excpetions. The sending of these auto-reaction messages can be configured directly in the BPMon Setup. Each monitoring object can be assigned a specific recipient or a list of recipients for the auto-reaction.

The link provides the detail information on how to create a monitoring object and assign notification:

https://websmp209.sap-ag.de/~sapdownload/011000358700006137532006E/BPMon_Setup_Guide.pdf

Before we can configure the notification part we have to provide the threshold values for the respective key figures in the monitoring object under the Monitoring Configuration tab. The alert will be triggered only when the measured value reaches the threshold. Now under the notification tab provide the details to send the notification email to the recipient.

figure 2.jpg

   Figure 2. Automatic Alert Notification uses BADI: CUST_MSG.

Note: Make sure that the flag ‘Customer – specific Notification’ is selected to call the BADI for customized email under filter for BADI_BUILD_MESSAGE.

Once all the required details are filled, SAVE the Monitoring Object, Generate and Activate. Then go to the Notification tab again and activate the notification.

figure 3.jpg

    Figure 3. Activating the alert notification.

Note: Without this step the notification will not be active even though the Alerting/Monitoring is active.

6.     BADI implementation for customized email

Customized notification messages with dynamically created content can be achieved by implementing one of the corresponding BADIs. SAP offers two BADIs each for notifications and service desk messages which enable you to either:

  • Create/modify the content of the notification messages which can be enriched with any necessary business context information (using BADI_BUILD_MESSAGE or BADI_BUILD_SUPNOTF) and send out via the standard BPMon framework.
  • Create/modify a notification message which can be enriched with any necessary business context information (using BADI_CUSTOM_MESSAGE or BADI_CUSTOM_SUPNOTF) and send out via user defined notification. 

Here we will customize the email using BADI_BUILD_MESSAGE.

In SAP solution manager, go to transaction code SE18 and give the BADI name as BADI_BUILD_MESSAGE to display.

figure 4.jpg

    Figure 4.  Initial screen for TCODE SE18.

Create ‘Z’ enhancement and BADI implementation for enhancement spot ENH_SPOT_DSWP_BPM_NOTIF as shown in figure 5.

figure 5.jpg

   Figure 5.  ‘Z’ enhancement and BADI implementation for customized email.

Create a filter value for BADI implementation and then double click on implementation class, followed by the double click on the method IF_EX_DSWP_MESSAGE~BUILD_NOTIFICATION as shown in figures 6 and 7.

figure 6.jpg

   Figure 6. Filter value for BADI implementation.

figure 7.jpg

   Figure 7. Implementing class and method for custom BADI.

7.     Method for customizing an email

ABAP code has to be written within IF_EX_DSWP_MESSAGE~BUILD_NOTIFICATION method. Suppose we want to create the customized email as per the following figure. The customized email has been tested with ‘IBM Lotus Notes’ and it works perfectly. A simple coding is used to create such a customized email. The code includes the method to retrieve the required fields from the alert table.

figure 8.jpg

   Figure 8. Customized Mail sent to ‘IBM Lotus Notes’

7.1    Changing the subject line as per alert level

The following code is used to change the subject line of an email which contains the severity of the alert along with the name of the monitoring object. The details are retrieved from the table IM_ALERT_TAB.

Note: Here you can’t make the subject line more than 50 words.

CODE:

FIELD-SYMBOLS: <ls_alerttab> LIKE LINE OF im_alert_tab.

LOOP AT im_alert_tab ASSIGNING <ls_alerttab>.  

monid = <ls_alerttab>-monid.

getalerttype = <ls_alerttab>-alerttype.

solsystem = <ls_alerttab>-alsysid.

rating = <ls_alerttab>-rating.           

ENDLOOP.

CONCATENATE rating ‘alert:’ im_mo_obj_descr INTO ex_subject SEPARATED BY space.

Here in the subject line the alert rating and monitoring object name is included. For output please refer the figure 8.

Note: You can insert a line or line space just by appending a string with value as ‘_’ (underscore with maximum 255 character line) and a blank space to ‘ex_soli_tab’ respectively.

7.2    Getting the solution and the system name

It is important to know for which solution and managed system an alert email is triggered. The solution name and managed system SID can be directly retrieved from import parameters (directly available for BADI method, starts with ‘ im_* ’). The solution name can be retrieved from im_alert_tab using LOOP statement as shown in the above code.

CODE:

DATA: line_out LIKE LINE OF ex_soli_tab.

CONCATENATE ‘Solution Name:’ im_soluname INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

CONCATENATE ‘Managed System:’ im_sid INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

CONCATENATE ‘Solman System:’ solsystem INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out. 

7.3   Getting context data

The context data include business scenario, process and the process step name on which a monitoring object is created and alert is triggered for the same. The context data is retrieved from the table IM_CONTEXT_TAB.

CODE:

FIELD-SYMBOLS:  <ls_steptab> TYPE AGS_BPM_STEP_OR_INTF.

LOOP AT im_context_tab ASSIGNING <ls_steptab>.

getscenario = <ls_steptab>-scenario_descr.

getstep = <ls_steptab>-step_descr.

ENDLOOP.

CONCATENATE ‘Business Scenario:’ getscenario INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

CONCATENATE ‘Business Process:’  im_pname INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

CONCATENATE ‘Step:’ getstep INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

7.4    Getting alert data

The alert data include the measured value of the key figure for the monitoring object. In this example as shown in figure 8, No. of Open Orders (sales order) is the key figure for which measured value is 126, more than the specified threshold value. This triggers the red alert along with email notification. The color of the text can be changed using html tags and alert rating (using IF statement). The alert generation date and time are converted into conventional format.

CODE:

FIELD-SYMBOLS: <get_alert> LIKE LINE OF im_alert_tab.

LOOP AT im_alert_tab ASSIGNING <get_alert>.

WRITE  <get_alert>-al_meas_value to  al_meas_value_c.

getatext = <get_alert>-atext.

CONCATENATE ‘Key figure:’ getatext INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

CONCATENATE <get_alert>-adate+6(2) <get_alert>-adate+4(2) <get_alert>-adate(4) INTO newdate SEPARATED BY ‘/’.

CONCATENATE <get_alert>-atime(2) <get_alert>-atime+2(2) <get_alert>-atime+4(2) INTO newtime SEPARATED BY ‘:’.

CONCATENATE ‘Measured Value:’ al_meas_value_c ‘@ DATE:’ newdate ‘ @ TIME:’ newtime INTO line_out-line SEPARATED BY space.

APPEND line_out TO ex_soli_tab.

clear line_out.

ENDLOOP.

7.5     Getting a link to the alert inbox

The following code allows to get the url link to the alert inbox of a Solution Manger system for detail analysis of alert in the notification email. Using this link, the responsible person can login to the SolMan system to view the measured values of alert.

CODE:

DATA:  lv_monobj_id TYPE string,

            lf_string TYPE string,

            lv_keyfigure TYPE string,

            lf_url(500)      TYPE c,

            lv_soli          TYPE soli,

            it_soli_tab      TYPE soli_tab,

            lt_url_table     LIKE STANDARD TABLE OF lf_url,

            lt_tline_tab     TYPE tline_tab,

            lv_proc_info TYPE dswp_bpm_proc_info.

       CONCATENATE im_monid ‘.’ getalerttype INTO lv_keyfigure.

        lv_monobj_id = lv_proc_info-objectno_mo.

        lf_string = cl_ags_bpm_alert_inbox=>construct_alert_inbox_url(       

            iv_solution_id   = im_solution_id

            iv_monobj_id     = lv_monobj_id

            iv_keyfigure     = lv_keyfigure ).

            lf_url = lf_string.

        * Convert to soli_tab

        APPEND lf_url TO lt_url_table.

        CALL FUNCTION ‘CONVERT_STREAM_TO_ITF_TEXT’

          EXPORTING

            language    = lv_proc_info-langu

          TABLES

            text_stream = lt_url_table

            itf_text    = lt_tline_tab.

        CALL FUNCTION ‘CONVERT_ITF_TO_STREAM_TEXT’

          EXPORTING

            language    = lv_proc_info-langu

          TABLES

            itf_text    = lt_tline_tab[]

            text_stream = it_soli_tab[].

        REFRESH: lt_tline_tab[], lt_url_table.

         LOOP AT it_soli_tab INTO lv_soli.

            APPEND lv_soli TO ex_soli_tab.

          ENDLOOP.

Note: You can add the link to the ‘Alert Detail List’ from the Web GUI to find out the objects which count as a measured value using the SAP note 1610494. 

7.6     Getting the detail of Monitoring Activities

The following code allows to get the detail of monitoring activities which is provided under the ‘Monitoring Activities’ tab while configuring the monitoring object. By this means we can provide further steps to be taken by the responsible person after getting the email notification.

CODE:

DATA: MA_tab TYPE AGS_BPM_MON_ACTIVITIES,

      Problem_indicator type string,

      Error_handling type string,

      Escalation_path TYPE string.

    

CALL METHOD CL_AGS_BPM_OPERATIONS=>GET_ALERTTYPE_MON_ACTIVITIES

    EXPORTING

      iv_solution       = im_solution

      iv_monid          = im_monid

      iv_alerttype      = ‘ ‘

      iv_spras          = im_spras

    IMPORTING

      es_mon_activities = MA_tab.

    CONCATENATE LINES OF MA_tab-T_PROB_INDIC INTO Problem_indicator.

    CONCATENATE LINES OF MA_tab-T_ERR_HANDL INTO Error_handling.

    CONCATENATE LINES OF MA_tab-T_ESCA_PATH INTO Escalation_path.

    CONCATENATE ‘<B>’   ‘Monitoring Activities:’   ‘</B>’   into line_out-line.

    APPEND line_out to ex_soli_tab.

    clear line_out.

 

    CONCATENATE ‘Problem Indicators:’   Problem_indicator  into   line_out-line.

    APPEND line_out to ex_soli_tab.

    clear line_out.

           

    CONCATENATE ‘Error Handling:’    Error_handling  into   line_out-line.

    APPEND line_out to ex_soli_tab.

    clear line_out.

           

    CONCATENATE ‘Escalation Path:’   Escalation_path  into   line_out-line.

    APPEND line_out to ex_soli_tab.

    clear line_out.

Detailed information on the BADI implementation can be found in the following guide:

https://websmp209.sap-ag.de/~sapdownload/011000358700000525622010E/Auto-reaction_Messages.pdf

8.     Conclusion

This document explains a simple code, which can be used to cater potentially critical situations proactively by triggering the customized email notification including all necessary alert information. The context data and the alert details help to find out the bottleneck at business scenario, business process and process step level.  The notification email will be triggered only when the measured value has crossed the defined threshold values. The role of BADI (BADI_BUILD_MESSAGE) in the Solution Manager system is to trigger a email with the details mentioned in the customized method.

About Author :

The autthor is part of RunSAP CoE team having expertise in SAP Solution Manager functionalities from ALM & RSlaF like Solution Documentation, SoDocA, Test Managemtent, BPCA, BPMon, BP Analystics JSM etc.

To report this post you need to login first.

7 Comments

You must be Logged on to comment or reply to a post.

  1. SAGAR PARIKH

    Customers do have specific requirements to receive email notifications in a specific format. This blog provides really good and helpful information for customized email notification.

    (0) 

Leave a Reply