Auto Replace of WI when user Cancels - A dodgy how to

Mark Pyc markpyc at hotmail.com
Fri Oct 22 09:45:21 EDT 2004


G'day all,
 
I think at some stage in the past there was a discussion on the issues
surrounding the cancel of WI's (esp User Decisions) that were sent to
mulitple recipients. The default system reaction of cancel is to cancel and
keep the WI in the inbox, but the WI is already reserved and therefore only
visible to the executing (and cancelling) user. If all responsible agents
are to see the WI again the executing agent must manually replace it.
 
It may be in some cases that the preferred logic would be a Cancel would
automatically include a Replace. In this way if a user decides they are not
responsible, all other agents would have immediate access to execute it.
 
Mucking around teaching the BIT610 course I developed a bit of a hack to do
this. When I say hack, I mean hack. There is no recommendation of the
stability or reliability of the code, but on the basis of 10 minutes testing
it seems to work.
 
It makes use of the Workitem Exit functionality (not certain which release
these become available). At any rate create a class that implements the
interface IF_SWF_IFS_WORKITEM_EXIT and implement the code below (see warning
above). In the step include the class in the Exit tab.
 
I've only tested this on a simple Workflow that contains a decision as it's
only step, but it seems to work nicely.
 
Anway, I'm just sharing a bit of WF nerd love.
 
Have fun,
Mark
 
 
method IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED .
 
  DATA:
    lv_wi_handle TYPE REF TO if_swf_run_wim_internal,
    ls_wihead TYPE swr_wihdr,
    ls_msg TYPE swr_mstruc.
 
  if im_event_name EQ 'AFT_EXEC'.
    ls_wihead = im_workitem_context->get_header( ).
    check ls_wihead-wi_stat = 'STARTED'.
 
    CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
      EXPORTING
        im_wiid             = ls_wihead-WI_ID
        im_read_for_update  = 'X'
        im_wait_for_enqueue = ' '
      RECEIVING
        re_instance         = lv_wi_handle.
 
    CALL METHOD lv_wi_handle->set_status
      EXPORTING
        im_new_status = swfco_wi_status_ready.
    .
    ls_msg-msgid = 'BC'.
    ls_msg-msgty = 'S'.
    ls_msg-msgno = '701'.
    ls_msg-msgv1 = 'WI Replaced on Cancel by EXIT'.
    CALL METHOD im_workitem_context->set_message_to_log
      EXPORTING
        im_message = ls_msg.
  endif.
 
endmethod.
 


More information about the SAP-WUG mailing list