Copyright 2024 - BV TallVision IT

Coding example for the creation of an event, which also places some data on the event container to be passed on to the flow (or task). The object key of the business object is supplied (required) in this case with a hardcoded purchase order number. Where the object key consists of more than one values, they should be concatenated together into the OBJKEY field (field length should be takeninto account, so do not use the CONCATENATE statement untested).

* The following include allows the use of the SWC_SET_ELEMENT macro. 
include <CNTAIN>.

data: begin of l_event,
       objtype like SWETYPECOU-objtype,
       objkey like SWEINSTCOU-objkey,
       event like SWETYPECOU-event,
     end of l_event,
     i_container like SWCONT occurs 0 with header line.

l_event-objtype = 'BUS2012'.    "Purchase order
l_event-objkey = '7701000001'.  "Dummy number (of actual PO)
l_event-event = 'VENDORCONFIRMATIONARRIVED'. "Event name

* Additional parameters are passed on via the event container, 
* the variables that are defined here should also be defined as event 
* parameters in the Business Object Builder. 
refresh i_container.
SWC_SET_ELEMENT i_container 'IDOCNUMBER' '80384'.
SWC_SET_ELEMENT i_container 'ITEMNUMBER' '00010'.

CALL FUNCTION 'SWE_EVENT_CREATE'
  EXPORTING
   OBJTYPE                       = l_event-objtype
   OBJKEY                        = l_event-objkey
   EVENT                         = l_event-event
 TABLES
   EVENT_CONTAINER               = i_container
 EXCEPTIONS
   OBJTYPE_NOT_FOUND             = 1
   OTHERS                        = 2.

* Please note: the event creation function does not commit,
* thus an explicit commit is required.
COMMIT WORK.