This section is relevant for ABAP developers, who want to implement and use the Backend Event Publisher (BEP) API in their source code.
You can use the API in your code to do the following:
Publish events that can occur in your custom business object.
Publish events that can occur due to changes in your custom workflow-based implementation. A typical use case is that you want to send notifications to end users who are using your custom workflow solution. In this case you add the calls to the BEP implementation class.
The BEP implementation class /IWBEP/CL_EVENT_MANAGER provides method PUBLISH_EVENT. This method handles events in the SAP system. It is an asynchronous service operation.
Name |
Optional/Mandatory |
Description |
---|---|---|
IV_EVENT_ID |
mandatory |
The event ID. The method imports this parameter. It uses the data type, Type, for table /IWBEP/EVENT_ID. |
IV_EVENT |
optional |
The event itself. The method imports this parameter. It uses the data type, Type, for table /IWBEP/EVENT. |
IV_OBJECT_ID |
mandatory |
The object ID. The method imports this parameter. It uses the data type, Type, for table /IWBEP/OBJ_ID. |
IV_ACTIVITY |
optional |
The actual event to be activated. The method imports this parameter. It uses the data type, Type, for table /IWBEP/ACTIVITY_NAME. |
IT_RECEIVERS |
optional |
The list of users subscribing to the event. The method imports this parameter. It uses the data type, Type, for table /IWBEP/T_SUB_USER. |
IT_TEXTS |
optional |
The texts for the event group. The method imports this parameter. It uses the data type, Type, for table IWBEP/T_EVENT_GRP_TEXT. |
IT_XNOTIF_PROPS |
optional |
The method imports this parameter. |
IS_XNOTIF_OBJECT |
optional |
The method imports this parameter. |
IV_XNOTIF_INLINES |
optional |
The method imports this parameter. |
Example report to send the user object notification to all subscribers at once.
REPORT test. data: lo_event_manager type ref to /iwbep/cl_event_manager, ls_address type bapiaddr3, lt_xnotif_props type /iwbep/t_xnotif_props, ls_xnotif_prop type /iwbep/s_xnotif_prop, ls_xnotif_object type /iwbep/s_sample_user, lv_object_id type /iwbep/obj_id, lt_return type table of bapiret2, ls_return type bapiret2, lt_subs type /iwbep/t_subscribers, ls_email type /iwbep/s_sample_user_email. parameters: p_user type syuname default sy-uname. start-of-selection. * get user data call function 'BAPI_USER_GET_DETAIL' exporting username = p_user importing address = ls_address tables return = lt_return. read table lt_return into ls_return with key type = 'E'. if sy-subrc = 0. message id ls_return-id type ls_return-type number ls_return-number. else. * fill XNotification properties ls_xnotif_prop-name = 'FIRSTNAME'. ls_xnotif_prop-value = ls_address-firstname. append ls_xnotif_prop to lt_xnotif_props. ls_xnotif_prop-name = 'LASTNAME'. ls_xnotif_prop-value = ls_address-lastname. append ls_xnotif_prop to lt_xnotif_props. * fill XNotification object ls_xnotif_object-name = ls_address-lastname. ls_xnotif_object-first_name = ls_address-firstname. ls_email-child_index = 1. ls_email-email = 'Email1'. append ls_email to ls_xnotif_object-emails. ls_email-child_index = 2. ls_email-email = 'Email2'. append ls_email to ls_xnotif_object-emails. * send event try. create object lo_event_manager. lv_object_id = p_user. call method lo_event_manager->publish_event exporting iv_event_id = 'SAMPLE_USER_CHANGED' iv_object_id = lv_object_id it_xnotif_props = lt_xnotif_props is_xnotif_object = ls_xnotif_object iv_xnotif_inlines = 'Emails'. catch /iwbep/cx_event_publisher. message 'Failed to send event' type 'E'. endtry. endif.
There are two Business Add-In (BAdI) interfaces in BEP:
/IWBEP/BADI_EVENT_PUBLISH
This BAdI extends editing capabilities for changing user text, or disable sending of an event, and it can be used as a customer-specific implementation.
Call this BAdI implementation before sending the event to SAP Gateway.
/IWBEP/BADI_SUBSCRIPTION
This BAdI is for authorization checks, disabling of the event, or allowing and disallowing subscriptions; and it can be used as a customer-specific implementation.
Call this BAdI implementation before saving the subscription data.