Home > SAP Tips > ABAP/Java developer tips > How to raise alerts from ABAP Proxy
SAP Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ABAP/JAVA DEVELOPER TIPS

How to raise alerts from ABAP Proxy


Sukumar Natarajan
01.26.2007
Rating: -4.60- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


In many cases, it is necessary to raise alerts from ABAP, such as when a business critical condition happens during processing. SAP provides a versatile function SALRT_CREATE_API for this purpose that we can use to populate the alert container and raise alerts.

Steps in XI
In our example, we will use a simple BPM. This has two steps, a receive step and a send step.

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:




The payload of the message is:
<?xml version="1.0" encoding="UTF-8"?>

<ns0:Vendor xmlns:ns0="urn:sukumar-test">
<VendorNumber>12345</VendorNumber>
<LastName>Smith</LastName>
<SearchTerm>Vendor12345</SearchTerm>
<Currency>USD</Currency>
<Address>
<Street>123 Main Street</Street>
<City>Plano</City>
<Zip>75075</Zip>
<Country>USA</Country>
</Address>
</ns0:Vendor>

Create the alert category
Using the transaction code ALRTCATDEF, an alert category ALRTFRMWRKTEST was created.

Define the container variables as below:
Container variables in alert definition:


The long & short texts are defined as:


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.

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 and 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 blog to know how to integrate Alerts into UWL.

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

Sukumar Natarajan works for XI Regional Implementation Group with SAP Labs.


This content is reposted from the SAP Developer Network.
Copyright 2007, SAP Developer Network

SAP Developer Network (SDN) is an active online community where ABAP, Java, .NET, and other cutting-edge technologies converge to form a resource and collaboration channel for SAP developers, consultants, integrators, and business analysts. SDN hosts a technical library, expert blogs, exclusive downloads and code samples, an extensive eLearning catalog, and active, moderated discussion forums. SDN membership is free.

Want to read more from this author? Click here to read Sukumar Natarajan's Weblog. Click here to read more about XI on SDN.



Rate this Tip
To rate tips, you must be a member of SearchSAP.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
ABAP/Java developer tips
Fixing a common OPEN_FORM and START_FORM error in SAPscript
Select Text fields: Case-insensitive
Finding BADIs you can use
Is this the quickest way to find a BADI?
ABAP Objects in SAP Workflow to provide improved performance
Easily debug error messages in SAP processes
Accessing private attributes in ABAP Objects
Find a BADI in a minute
Top 10 SAP tips of 2007
How to transport an SAP query in R/3 4.6x

SAP ABAP
The difference between an SAP system and a non-SAP system
Is C, C++ and Java knowledge required when learning SAP?
Getting started with a NetWeaver career
How to be a self-taught NetWeaver and ABAP expert
Is SAP BI knowledge advantageous to an ABAP user?
An ABAP user wants to learn XI
Select Text fields: Case-insensitive
Finding BADIs you can use
Is ABAP knowledge necessary for SAP BI?
SAP ABAP development quiz
SAP ABAP Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
ABAP  (SearchSAP.com)
ABAP Objects  (SearchSAP.com)
ABAP Workbench  (SearchSAP.com)
BAPI  (SearchSAP.com)
CATT  (SearchSAP.com)
R/3 Repository  (SearchSAP.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



NetWeaver SAP White Papers
HomeNewsTopicsBlogsTipsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
SearchSAP.com is a search service provided by TechTarget and is completely
independent of and not affiliated with SAP AG.
  TechTarget - The IT Media ROI Experts