Creation of Events by Using ABAP
Classes
You must ensure that the event is triggered when the status change occurs. It may be necessary to trigger the event in your program by using an ABAP class method.
Note that events say something about object status changes that have actually occurred. Therefore, ensure that the event is not created until the relevant status change has taken place. To do this, call the method for creating an event in the same logical unit of work (LUW) that the status change is made in.
The triggering of events described here relates to events that are processed by the event manager. These events must be triggered by the ABAP class CL_SWF_EVT_EVENT.
If an event is triggered by the following ABAP objects command, this has no significance for the event manager:
RAISE EVENT <evt> EXPORTING... <ei> = <f i>...
However, in the
event handler method the event can be triggered for the event manager
by using the ABAP class
CL_SWF_EVT_EVENT. See
also:
ABAP
Objects -> Triggering and Handling Events.
There are implementation examples in the CL_SWF_FORMABSENCdemo class. To trigger the event, use a static method (method: DELETE of the demo class) or an instance method (method: UPDATE of the demo class).
For a description of the internal processing, see Creation of Events by Calling a Function Module. The ABAP class CL_SWF_EVT_EVENT has two methods, RAISE and RAISE_IN_UPDATE_TASK, which behave in the same way as the function modules SWE_EVENT_CREATE and SWE_EVENT_CREATE_FOR_UPD_TASK.

It is not possible to state whether the receiver was successful. For more information, see Evaluation and Maintenance of Type Linkages.

Ensure that you write the database changes first, then call the method to trigger the event, and finally carry out a COMMIT WORK. If you perform these activities in a different order, it can lead to object data not existing in the container, or having incorrect content.
The following parameters must be provided, regardless of whether the event is triggered by a static method or an instance method (see also: demo class):
|
Import parameters |
Type |
Meaning |
|
im_objcateg |
SWF_CLSTYP |
Workflow object type: · MC_OBJCATEG_CL (constant of the CL_SWF_EVT_EVENT class) for an ABAP class · MC_OBJCATEG_BOR (constant of the CL_SWF_EVT_EVENT class) for a BOR object |
|
im_objtype |
C |
ID of the object type, ID of the ABAP class |
|
im_event |
C |
ID of the event |
|
im_objkey |
C |
Object key |
To set the event parameters, use the IF_SWF_IFS_PARAMETER_CONTAINER interface. Use the SET method of this interface to set the relevant parameters.
Use the TRY ... ENDTRY instruction to catch the exceptions cx_swf_evt_execption (error in event creation) and cx_swf_cnt_container (error in setting a parameter).

Since the asynchronous RFC for calling the receiver function module is not triggered until after the next COMMIT WORK, you must initiate the command COMMIT WORK in your application after the method for creating an event is called in order for the events to actually be created.
The database commit performed automatically with a screen change does not trigger the asynchronous RFC.