Skip to Content
Introduction

There are many cases where it is necessary to reaise alerts from ABAP. For example, when a business critical condition happens during processing. SAP provides a function SALRT_CREATE_API for this purpose. This is a versatile function using which we can populate the alert container and raise alerts.

Steps in XI

In our example, we will use a simple BPM. This has 2 steps, a receive step and a send step.

image

The send step sends a message to inbound ABAP proxy (client proxy). Here is where we will use the function SALRT_CREATE_API to raise an alert.
The property of the send step:

image

The payload of the message is:

image

Define the container variables as below:

Container variables in alert definition:

image

The long & short texts are defined as:

image

These variables will be substituted at runtime.

When the inbound proxy is executed in the backend system, it triggers an alert.

If transaction ALRTDISP is executed, the alert can be seen and the container values can be displayed.

image

Finally the abap code

Please note that the version of SALERT_CREATE_API used here is XI 3.0. The signature of the function is different in XI 7.0 version.

The code for inbound proxy, specifically, the method ZII_VENDOR_FILE~EXECUTE_ASYNCHRONOUS is:

method ZII_VENDOR_FILE~EXECUTE_ASYNCHRONOUS.

      • **** INSERT IMPLEMENTATION HERE **** ***

  data: l_r_cnt type ref to IF_SWF_CNT_CONTAINER.

  data: l_t_receipients type table of SALRTSRCP.

  data: l_s_receipients type SALRTSRCP.

  data: l_t_container type table of SWCONT.

  data: l_s_container type swcont.

  data: begin of l_wi_head,

        wi_id type SWWWIHEAD-wi_id,

        CREA_TMP type swwwiHead-CREA_TMP,

        end of l_wi_head.

  data l_t_wi_head like standard table of l_wi_head with key wi_id.

  l_s_receipients-uname = ‘SUKUMAR’.

  append l_s_receipients to l_t_receipients.

  l_r_cnt = cl_swf_cnt_factory=>create( ).

  select wi_id CREA_TMP from swwwihead client specified into

corresponding fields of table l_t_wi_head

         where client = ‘100’.

  • 100 is the Integration server client

  sort l_t_wi_head by crea_tmp descending.

  loop at l_t_wi_head into l_wi_head.

    exit.

  endloop.

  • Provide the container element name, value,length & type

  • Move the data to the container variable

  l_s_container-element = ‘VENDOR’.

  l_s_container-value = input-Vendor-Vendor_Number.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘LASTNAME’.

  l_s_container-value = input-vendor-last_name.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘SEARCHTERM’.

  l_s_container-value =  input-vendor-search_Term.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘CURRENCY’.

  l_s_container-value =  input-vendor-currency.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘STREETADDRESS’.

  l_s_container-value =  input-vendor-address-Street.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘CITY’.

  l_s_container-value =  input-Vendor-address-city.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘ZIP’.

  l_s_container-value =  input-Vendor-address-zip.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘COUNTRY’.

  l_s_container-value =  input-Vendor-address-country.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  l_s_container-element = ‘EMAIL’.

  l_s_container-value =  ‘sukumar.natarajan@sap.com‘.

  l_s_container-elemlength = 20.

  l_s_container-TYPE =’C’.

  append l_s_container to l_t_container.

  CALL FUNCTION ‘SALRT_CREATE_API’

    EXPORTING

      IP_CATEGORY                  = ‘ALRTFRMWRKTEST’

  •                    IP_EXPIRATION_TIME           =

  •                    IP_EXPIRATION_DATE           =

       IP_WAIT_ON_COMMIT            = ”

  •                    IP_APPLICATION_GUID          =

  •                    IP_GET_SYNC_EXCEPTIONS       = ‘ ‘

  •                  IMPORTING

  •                    EP_ALERT_ID                  =

   TABLES

    IT_RECIPIENTS                = l_t_receipients

  •                    IT_ACTIVITIES                =

     IT_CONTAINER                 = l_t_container

  •                    IT_EXT_RECIPIENTS            =

  •                    IT_EXT_ADDR                  =

  •                    IT_ROLES                     =

  •                  EXCEPTIONS

  •                    ALERT_CATEGORY_UNKNOWN       = 1

  •                    ALERT_NO_RECIPIENTS          = 2

  •                    ALERT_ERROR_UNKNOWN          = 3

  •                    DESTINATION_UNDEFINED        = 4

  •                    COMMUNICATION_FAILURE        = 5

  •                    SYSTEM_FAILURE               = 6

  •                    OTHERS                       = 7

            .

  IF SY-SUBRC <> 0.

  if sy-subrc <> 0.

    exit.

  endif.

  commit work.

endmethod.

Unfortunately, in the function, we still need to provide the container variable name and its length.

Read this Integrating Alerts into UWL – it’s no problem! to know how to integrate Alerts into UWL.

After configuring the UWL, you can see the alerts there.

image image

To report this post you need to login first.

3 Comments

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

  1. Laxman Molugu
    Hi Sukumar,

    When I was with SAP I heard a lot about you(all great things though 🙂 ) but I never got an opputunity to meet you.

    I am just wondering why do we need to implement alert in proxy classes(with lot of coding), can’t we use the XI Alert framework to raise alerts?

    what I mean to say is, we can configure XI alert framework to notify any errors in Adapter Engine, XI-Integration Engine and also BPM processes. Proxy client/Server is also a component/part of the XI end-end Integration so I am wondering XI alert framework can recognize the errors in proxy and notify using alert frameowrk??

    Is that possible??

    (0) 
    1. Sukumar Natarajan Post author
      Hi Laxman,
      Not sure if I understand your question.
      But what I want to highlight in the blog is to show that its possible to raise alerts within business systems. You may have cases where the alerts may be raised based on business rules and these may be harder or impractical to implement in the XI business processes. So this is another way to raise the alerts.
      Hope this helps….
      (0) 
  2. Jayshree Kamlapure
    Hi Sukumar,
    This is really very helpful blog to understand how to trigger alerts.
    But i want to know that, is it possible to pass multiple values to the it_container?

    In above example,can we provide multipl vales to VENDOR,LASTNAME,SEARCHTERM,CURRENCY,STREETADDRESS,CITY ETC.

    I have tried this the same above example but in case of multiple values its taking only latest and single value (record).

    Then if i want to send multiple records through alert what should i do?

    (0) 

Leave a Reply