cancel
Showing results for 
Search instead for 
Did you mean: 

Start Event in workflow not working using CL_SWF_EVT_EVENT=>RAISE

juliusku
Participant

Hello Everybody,

I have been working on this for a couple of days and this is my first time doing WF. I think I have gone far but now I am struggling here.

The problem is that I cannot run the workflow raising an event. I don't get any message on debugg, but when I use SWUE It works perfectly and I see it on SWI1.

I don't even get any error during debugg:

I appreciate the help

Thanks,

I created a WF with a START EVENT that should trigger from the class:

This is how the WF START Event looks like with the bindings:

This is how my class looks like and I already added the code for all the IF_WORKFLOW methods:

Here is the code for the program i created to call my class TRIGGER_START_WF:


SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

REPORT zwftestjkl.


DATA: lr_wf TYPE REF TO zcl_plant2.

DATA: lv_werks TYPE werks.

lv_werks = '0010'.

CREATE OBJECT lr_wf

  EXPORTING

    plant = lv_werks.


CALL METHOD lr_wf->trigger_start_wf

    .

Here is the code for the TRIGGER_START_WF method:


SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

  METHOD trigger_sTART_wf.



* Data Declarations

    DATA: lv_class            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_plant            TYPE WERKS.



    lv_objkey = me->plant.

    lv_class = 'ZCL_PLANT2'.

    lv_event   = 'START_WF'.



* 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_class

        im_event     = lv_event

      RECEIVING

        re_reference = lr_event_parameters.


* Set up the name/value pair to be added to the container


    TRY.


        lv_param_name  = 'WFID'.  " parameter name of the event

        lv_plant         =  me->plant.


        CALL METHOD lr_event_parameters->set

          EXPORTING

            name  = lv_param_name

            value = lv_plant.


        lv_param_name  = 'I_CL_PLANT'.  " parameter name of the event

        CALL METHOD lr_event_parameters->set

          EXPORTING

            name  = lv_param_name

            value = me.


      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 event container

    TRY.

        CALL METHOD cl_swf_evt_event=>raise

          EXPORTING

            im_objcateg        = cl_swf_evt_event=>mc_objcateg_cl

            im_objtype         = lv_class

            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.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member

Hello Julius,

Have you done linkage in Tcode SWE2 for your class and workflow template . And also on event trace and run tcode SWEL to check your workflow triggered or not .

Regards,

Manoj Rawat

bpawanchand
Active Contributor
0 Kudos

Hi,

Some where in your binding definitions I see that there is no binding definiton between WFID event container element to any of the workflow container element. I assume it could be because of the missing binding definitions.

Thanks,Pavan

anjan_paul
Active Contributor
0 Kudos

hi,

Also you check the parameter WFID and I_CL_PLANT is same name or not?

sbl
Active Contributor
0 Kudos

Humm

May be you should start the event trace in SWELS and try then check in SWEL if something was raised

Cheers

Stephane

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Julius

Check the methods lpor & find_by_lpor are working correctly

In particular check your class attribute that persists the lpor value is formulated correctly & contains the correct content at runtime ... ie with class, class id, and object key - not just plant number

Make sure you have read and applied all of the ABAP OO for workflow blogs.

If you skipped anything take another look.

Also check also in Txn SM58 & ST22 in case something else is going on

Good luck

Rgds

Jocelyn