Skip to Content

Triggering workflow WS00500001


Hi Experts,

Please let me know how to trigger the WF - WS00500001 with object type - CL_EHHSS_PCO_INC_LC and Event - CREATED. And given data below.

1.       Title / Event :

  Table: EHHSSD_INC_BINFA

Field name: TITLE

Data element: EHHSS_INC_TITLE

Data type (Format): Character format

Length: 80 characters

2.       Data and Time

Table: EHHSSD_INC_BINFA

Field name: DATETIME_CR

Data Element: /BOBF/DATETIME_CR

Data type(Format): System format (Example : 31.07.2014 time  10:00 )

Length:  15

3.       Incident Reporter

Table: EHHSSD_INC_BINFA

Field name: USER_ID_CR

Data Element: /BOBF/USER_ID_CR

Data Type(Format): CHARACTER

Length: 12 Characters

4.       Locations

Table: EHHSSD_INC_BINFA

Field name:  LOC_ROOT_KEY_REF

Data Element: EHFND_LOCATION_KEY_REF

Data Type(Format): RAW (It will accept characters and numbers )

Length: 16

 

5.       Vehicle details

Table: EHHSSD_INC_VEHIC

Field for vehicle description: VEHICLE_DESC

Data element for vehicle description: EHFND_VEHICLE_DESC

Data type(Format): CHARACTER

Length: 40

Failed to trigger with below code 😔

    CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      OBJTYPE           = 'CL_EHHSS_PCO_INC_LC'
      OBJKEY            =   LV_REPORT

       EVENT             = 'CREATED'
    TABLES
      EVENT_CONTAINER   = GIT_EVT
    EXCEPTIONS
      OBJTYPE_NOT_FOUND = 1
      OTHERS            = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards,

Srivijay

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Sep 25, 2014 at 05:40 AM

    Issue resolved, able to trigger it with below code.

    DATA: lv_objtype           TYPE sibftypeid,
    lv_event             TYPE sibfevent,
    lr_event_parameters  TYPE REF TO if_swf_ifs_parameter_container,
    lv_TITLE_EVENT       type char80,
    lv_DATE_TIME         type char15,
    lv_INCIDENT_REPORTER type char12,
    lv_LOCATION1          type char16,
    VEHICLE_DETAILS      type char15.


    lv_objtype = 'CL_EHHSS_PCO_INC_LC'.
    lv_event   = 'CREATED'.
    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        .

    lv_TITLE_EVENT       = LV_TITLE.
    lv_DATE_TIME         = lv_date.
    lv_INCIDENT_REPORTER = LV_REPORTER.
    lv_LOCATION1         = LV_LOCATION.
    VEHICLE_DETAILS      = LV_VEHICLE.
    try.
    CALL METHOD lr_event_parameters->set
    EXPORTING
    name  = 'TITLE'
    value = lv_TITLE_EVENT.

    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.

    data: lv_key type char20.
    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_key
    IM_EVENT_CONTAINER = lr_event_parameters       .

    CATCH CX_SWF_EVT_INVALID_OBJTYPE .
    CATCH CX_SWF_EVT_INVALID_EVENT .
    ENDTRY.
    commit WORK.




    Thank you Siraj, Murali and Rick for your kind responses :-)



    Regards,

    Srivijay

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 16, 2014 at 05:39 PM

    Hi Srivijay,

    Try trigger the workflow using this FM "SAP_WAPI_CREATE_EVENT".

    Let me know if its not successfully.

    Regards,

    Siraj

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 16, 2014 at 06:13 PM

    Hi SriVijay,

    Try to trigger the event with FM SAP_WAPI_CREATE_EVENT .

    If you want to trigger a specific workflow you can use FM SAP_WAPI_START_WORKFLOW, here you can directly mention WS00500001 in the Task.

    Regards,
    Murali Krishna.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Srivijay Dinnimath

      Hello,

      If you use SAP_WAPI_START_WORKFLOW then the workflow template (WS) needs to be set to General Task.


      Again, you should try to use events instead of starting workflows directly. Surely there is an object instance associated with your workflow?

      regards

      Rick Bakker

  • avatar image
    Former Member
    Sep 16, 2014 at 08:30 PM

    Hello,

    Always try to use an event to start a workflow instead of starting it directly.

    As stated above, you should use SAP_WAPI_CREATE_EVENT.

    Is the event being created? Check in SWEL (may need to turn it on via SWELS).

    If so, check that the event is linked to the workflow by looking in the Start Events of the workflow.

    regards

    Rick Bakker

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 15, 2015 at 12:03 PM

    Hi Srivijay,

    I getting empty work item when in workflow when executed these code.

    Appreciate if you could give some tips.

    DATA: lv_objtype           TYPE sibftypeid,

    lv_event             TYPE sibfevent,

    lr_event_parameters  TYPE REF TO if_swf_ifs_parameter_container,

    lv_TITLE_EVENT       type char80,

    lv_DATE_TIME         type char15,

    lv_INCIDENT_REPORTER type char12,

    lv_LOCATION1          type char16,

    VEHICLE_DETAILS      type char15.

    lv_objtype = 'CL_EHHSS_PCO_INC_LC'.

    lv_event   = 'CREATED'.

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

    try.

         CALL METHOD lr_event_parameters->set

           EXPORTING

             name  = 'TITLE'

             value = 'test_150520151'.

       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.

    try.

         CALL METHOD lr_event_parameters->set

           EXPORTING

             name  = 'START_TIMESTAMP'

             value = '15.05.2015 00:00:00'.

       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.

    try.

         CALL METHOD lr_event_parameters->set

           EXPORTING

             name  = 'ID'

             value = 'DXXXXX'.

       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.

    data: lv_key type char20.

    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_key

             IM_EVENT_CONTAINER = lr_event_parameters.

       CATCH CX_SWF_EVT_INVALID_OBJTYPE .

       CATCH CX_SWF_EVT_INVALID_EVENT .

    ENDTRY.

    commit WORK.


    Regards,


    Add comment
    10|10000 characters needed characters exceeded