cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger Custom Workflow using OOABAP Class Events in SAP ABAP

lakshmanjk
Explorer
0 Kudos
3,244

Hi All,

I have created a custom workflow with a custom ABAP class and method along with Events. I am trying to execute the method to trigger the event manually but nothing happens and I dont see any error also during execution of below code. Also I would like to know how to get the Workflow Number after triggering the event and how to log custom error messages along with standard workflow logs. Appreciate your help.

METHOD trigger_event.
* Data Declarations
DATA: lv_objtype TYPE sibftypeid,
lv_event TYPE sibfevent,
lv_objkey TYPE sibfinstid,
lr_event_parameters TYPE REF TO if_swf_ifs_parameter_container,
lv_param_name TYPE swfdname,
lv_id TYPE zpm_s_activityset.

* Setting values of Event Name
lv_objtype = 'ZCL_MASS_INT_UPDATE'.
lv_event = 'TRIGGER_WORKFLOW'.

* Instantiate an empty event container
CALL METHOD cl_swf_evt_event=>get_event_container
EXPORTING
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
im_objtype = lv_objtype
im_event = lv_event
RECEIVING
re_reference = lr_event_parameters.

* Set up the name/value pair to be added to the container
lv_param_name = 'ITAB'. ->Internal table received from ODATA service
lv_id = itab[].

* Add the name/value pair to the event conainer
TRY.
CALL METHOD lr_event_parameters->set
EXPORTING
name = lv_param_name
value = lv_id.

CATCH cx_swf_cnt_cont_access_denied .
CATCH cx_swf_cnt_elem_access_denied .
CATCH cx_swf_cnt_elem_not_found .
CATCH cx_swf_cnt_elem_type_conflict .
CATCH cx_swf_cnt_unit_type_conflict .
CATCH cx_swf_cnt_elem_def_invalid .
CATCH cx_swf_cnt_container .
ENDTRY.

* Raise the event passing the prepared event container
TRY.
CALL METHOD cl_swf_evt_event=>raise
EXPORTING
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
im_objtype = lv_objtype
im_event = lv_event
im_objkey = lv_objkey
im_event_container = lr_event_parameters.
CATCH cx_swf_evt_invalid_objtype .
CATCH cx_swf_evt_invalid_event .
ENDTRY.

COMMIT WORK.
ENDMETHOD.

egor_malov
Contributor
0 Kudos

Hi,

you might find some answers in this blog: https://blogs.sap.com/2006/07/27/raising-abap-oo-events-for-workflow/

View Entire Topic
former_member186746
Active Contributor
0 Kudos

Hi,

Activate the event log to see if the event is raised correctly, maybe the receiving workflow is expecting an obligatory event parameter as import.

(SWELS, SWEL)

Kind regards, Rob Dielemans