Login Form

Best viewed in IE 7.0

ADVERTISEMENTS
ADVERTISEMENT

Triggering events in SAP

You can trigger an event in the following ways:
1) From an ABAP program using the RAISE method of the CL_BATCH_EVENT class.
The code excerpt below shows how you can use the CL_BATCH_EVENT class to trigger an event from an ABAP program.
DATA:
   p_eventid   TYPE btceventid,
   p_eventparm TYPE btcevtparm,
   p_server    TYPE btcserver.
 
* Obligatory parameter: EventID.
* EventID should be an existing event already defined in transaction
* SM64 or using CREATE method of class CL_BATCH_EVENT:
 p_eventid   = 'Z_TEST'.
* Optional parameters: event parameter and target server.
 p_eventparm = 'Event parameter'.
 p_server    = ''.

 CALL METHOD cl_batch_event=>raise
   EXPORTING
     i_eventparm                    = p_eventparm
     i_server                       = p_server
     i_eventid                      = p_eventid
   EXCEPTIONS
     excpt_raise_failed             = 1
     excpt_server_accepts_no_events = 2
     excpt_raise_forbidden          = 3
     excpt_unknown_event            = 4
     excpt_no_authority             = 5
     OTHERS                         = 6.

2) From an external to SAP program, use the SAP program SAPEVT.
The syntax for SAPEVT is as follows: sapevt <EVENTID> [-p <EVENTPARM>] [-t] pf=<Profile Name>|name=<SAP system name> nr=<SAP system mumber>
The SAPEVT parameters are as follows:
● <EVENTID>: The name of the event as defined in the SAP system with transaction SM64.
● -p <EVENTPARM>: An optional argument for the EVENTID which qualifies the event. The EVENTPARM is not defined in the SAP system.
● -t: Causes SAPEVT to log its actions in a short trace file. You can find the trace file in the current directory of the user who called SAPEVT.
● pf=<Profile Name> or name=<SAP system name> nr=<SAP system mumber>: Either pf or name and nr identify the SAP system in which the event is to be triggered.
At least one instance of the SAP system must be active when SAPEVT runs. Otherwise, the system will not know that the event has occurred. The instance must have the number specified in the SAPEVT call.
In more detail, the parameters for identifying the SAP system are as follows:
– pf <Profile Name>: Enter the name of the profile with which the SAP background processing instance(s) are started. SAPEVT identifies the SAP system from the specifications in the profile.
You can find SAP system profiles in the globally shared SAP directory SYS\profile (Windows NT), or SYS/profile (UNIX).
– name=<SAP system name> nr=<SAP system number>: The name of the SAP system (SID) and the SAP system number.

Requirements for Using SAPEVT
To use SAPEVT to trigger an event, the following requirements must be met:
● An SAP instance that offers background processing must be running or the start of jobs waiting on the event will be delayed.
If no instance in an SAP system is active when an external program triggers an event, than the event is ignored, the SAP system will not know that the event has occurred.
If a job that was scheduled to run when an event occurs cannot be started immediately, it is rescheduled as an immediate-start job. It will then be run at the earliest possible opportunity.
● If SAPEVT is started with a profile name as an argument, then the program must have access to the shared profile directory of the SAP system. SAPEVT needs to read the profile of the system to which it is sending the event.
If access to the directory is not possible, then you can create a local profile for SAPEVT. This profile need only contain values for the parameters rdisp/mshost and rdisp/msserv. Take the values from the profiles of the target SAP system. Specify the local profile in the SAPEVT command line.
● Network connection: SAPEVT must be able to establish a TCP connection to the SAP instance.
SAPEVT reports problems in establishing a connection to the SAP system in its log file.
● User search path: The SAP executables and profile directories must lie in the search path of the user who starts the program that calls SAPEVT.
UNIX: /usr/sap/<SAP system ID>/SYS/exe/run and SYS/profile
Windows NT: \\<Host Name>\sapmnt\<SAP system ID>\SYS\exe\run and SYS\profile

3) From SAPGUI.
You can trigger an event from SAPGUI when, for example, you want to test the behavior of the event or of the jobs waiting for that event.
You can trigger events in two ways:
● Simple trigger
The event is raised only in the local system. You can call a simple trigger from within two locations:
○ From the event history (transaction SM62) which contains the events that were already raised in the system.
○ From the list of locally defined events (transaction SM64).
● Extended trigger
The event can be raised in the local system, in another system, or by using sapevt.
ADVERTISEMENT
Free software downloads