Creation of Events by Using ABAP Classes

Use

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.

Prerequisites

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.

Features

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.

There are implementation examples in the demo class: CL_SWF_FORMABSENC. 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.

Activities

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 Parameter

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

Event Name

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).