You can trigger events with the function Background Events: Overview and Administration (transaction SM64). There is a distinction between system events and user events. System events are events predefined by SAP that you cannot modify and, if possible, you should not trigger manually.
As the figure above shows, events can be triggered in several ways:
Manually, using transaction SM64.
By the ABAP program BTC_EVENT_RAISE (see SAP Note 919458 – Program 'BTC_EVENT_RAISE') or by calling the function module BP_EVENT_RAISE.
At the operating system level, through program sapevt.
Using HTTP(S) by calling the ICF service /default_host/sap/bc/batch/event_raise.
Note
There are even different options (not included in the list above), such as to use the RAISE method of class CL_BATCH_EVENT.
When an event is triggered, a parameter can also be provided. In this way, you can define jobs that wait for the occurrence of the event together with the specified parameter.
You can display a history of events in the Event History (transaction SM62).
Note
For error analysis, SAP Note 1645120: Trigger of a background event is unknown may help.
sapevt is a program located in kernel directory which is used to trigger an event from a program running outside the SAP system. The syntax for the sapevt program is shown in the figure above.
- Example: sapevt myevent name=S4D pf=/usr/sap/S4D/SYS/profile/S4D_D11_s4dhost.
sapevt writes its output in a trace file dev_evt in the directory from where sapevt was called.
Note
SAP Note 802172: sapevt (Version 4): Release-independent version describes the individual parameters in detail. In addition, SAP Note 826779 – sapevt (Version 5): Security settings in the Msg. might be helpful if the sapevt program must use a different port to communicate with the message server due to increased security requirements.
To be able to react to external events, the SAP system must be active. Otherwise an event triggered by an external program is lost.
Hint
If the name of the event contains a blank character, you must specify the event in quotation marks when you call sapevt.
- For example: sapevt "my event" name=S4D pf=/usr/sap/S4D/SYS/profile/S4D_D11_s4dhost.
Note
If you want to call sapevt from a remote host, refer to SAP Note 374379: Triggering SAPEVT from a remote host.
The figure Examples of sapevt Calls shows further details.
Due to unavoidable changes as of Kernel 7.40 in the internal SAP message format, there is a break in sapevt in kernel release 7.40 when used on a cross-release basis. In addition, since sapevt communicates unauthorizedly with the message server, the program may no longer function in general if secure message server communication is active.
When sapevt is called on the application server with the user <sid>adm the parameter pf=<instance profile> must be provided. This behavior depends on the type of the operating system and the release and patch level of the kernel of the SAP system. Newer SAP systems on Windows require this input, on Linux it might be that an error message will be returned, but the event might have been raised successfully.
So if in doubt, provide pf=<instance profile>.
SAP provides two more options to trigger a batch event externally.
ICF service /default_host/sap/bc/batch/event_raise (see the figure below and SAP Note 2001336 – Downport: ICF service for triggering batch event and its attached PDF) .
RFC client sapevt_rfc on operating system level which calls function module BP_REMOTE_EVENT_RAISE (see SAP Notes 2015788 – Program "sapevt_rfc" and 2014139 – Function BP_REMOTE_EVENT_RAISE).
Regarding the ICF service /default_host/sap/bc/batch/event_raise, you have several options:
A user and password is stored in the section Logon Data of the ICF service. Then it is sufficient to pass to the http client a parameter string like the following to trigger the event SAP_TEST: http://<host name>:<ICM-Port>/sap/bc/batch/event_raise?sap-client=<client>&eventid=SAP_TEST. This call is basically equivalent to a call of the old program sapevt, because it does not require authentication.
Specify the logon data in the parameter string (at least for testing) . This would result in http://<host name>:<ICM-Por>t/sap/bc/batch/event_raise?sap-client=<client>&sap-user=<user name>&sap-password=<password>&eventid=SAP_TEST.
It is also possible to logon with X.509 certificates.
Additional Information