Skip to Content

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

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Feb 24, 2019 at 11:19 AM

    Hi,

    I would suggest checking the below points:

    1. What is the Business class Key? I couldn't see in your code passing the key of the business class "LV_OBJKEY.
    2. Make sure all the mandatory event container elements are passed in "LR_EVENT_PARAMETERS". Keep in mind that the name of the container element is case-sensitive.
    3. "lv_id TYPE zpm_s_activity set." are you sure is this a table type? For me it seems to be a work area or structure if following some naming conventions.

    Thanks

    Pavan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 25, 2019 at 08:51 AM

    Hi,

    How do you know that workflow not triggered? You can use fm SAP_WAPI_WORKITEMS_TO_OBJECT to find the workitems related to object.

    Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 25, 2019 at 10:56 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.