Triggering alert (Email) using java mapping

Click here for the tutorial

Function Module (Z_CREATE_ALERT) 

FUNCTION Z_CREATE_ALERT.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IP_CATEGORY) TYPE SALRTDCAT
*" VALUE(MESSAGE) TYPE CHAR100
*" VALUE(MESSAGE_ID) TYPE SXMSMGUIDC OPTIONAL
*" VALUE(SENDER_SERVICE) TYPE SXI_FROM_SERVICE OPTIONAL
*" VALUE(SENDER_INTERFACE) TYPE SXI_FROM_ACTION OPTIONAL
*" VALUE(RECEIVER_SERVICE) TYPE SXI_TO_SERVICE OPTIONAL
*" VALUE(RECEIER_INTERFACE) TYPE SXI_TO_ACTION OPTIONAL
*"----------------------------------------------------------------------
* Here, you find almost all constants, which are relevant for
* the Alert Framework.
TYPE-POOLS:
salrt.

CONSTANTS:
* Name of your alert category
c_category TYPE salrtdcat VALUE 'Z_SABU_TEST_01',
* Name of application specific attribute / container element
c_docnumber TYPE swfdname VALUE 'DOCNUMBER',
c_message type swfdname value 'MESSAGE',
c_guid type swfdname value 'SXMS_MSG_GUID',
c_sender type swfdname value 'SXMS_FROM_SERVICE',
c_s_int type swfdname value 'SXMS_FROM_INTERFACE',
c_receiver type swfdname value 'SXMS_TO_SERVICE',
c_r_int type swfdname value 'SXMS_TO_INTERFACE'.

* Declaration of the alert-container including application data
DATA: li_container TYPE REF TO if_swf_cnt_container.

TRY.
li_container = cl_swf_cnt_factory=>create( ).
CATCH cx_swf_utl_no_instance_found
cx_swf_utl_obj_create_failed .
ENDTRY.

* Fill in the container variables as an element of the container
TRY.
li_container->element_set(
name = c_docnumber
value = 'IDD0430' ).

li_container->element_set(
name = c_message
value = MESSAGE ).

li_container->element_set(
name = c_guid
value = MESSAGE_ID ).

li_container->element_set(
name = c_sender
value = SENDER_SERVICE ).

li_container->element_set(
name = c_s_int
value = SENDER_INTERFACE ).

li_container->element_set(
name = c_receiver
value = RECEIVER_SERVICE ).

li_container->element_set(
name = c_r_int
value = RECEIER_INTERFACE ).

CATCH cx_swf_cnt_cont_access_denied
cx_swf_cnt_elem_not_found
cx_swf_cnt_elem_access_denied
cx_swf_cnt_elem_type_conflict
cx_swf_cnt_unit_type_conflict
cx_swf_cnt_elem_def_invalid
cx_swf_cnt_invalid_qname
cx_swf_cnt_container .
ENDTRY.

* Create an alert of category 'Z_SABU_TEST_01'.
* Recipient, texts and other attributes are added from
* the definition of the alert category, i.e. the document
* number is the only dynamic element of this API call.
CALL FUNCTION 'SALRT_CREATE_API'
EXPORTING
ip_category = c_category
ii_container = li_container
ip_wait_on_commit = salrt_true "An explicite COMMIT WORK statement
"within the application is mandatory for
"the alert delivery.
EXCEPTIONS
OTHERS = 1.

IF sy-subrc NE 0.
* message "error when creating alert
ENDIF.

* Here is our COMMIT WORK
COMMIT WORK.

endfunction.

 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image