Skip to Content
0
Former Member
Jan 22, 2015 at 11:25 AM

Shopping cart standard workflow workitem not getting forwarded to substitute

252 Views

We have maintained one substitute for user say 'ABC', substitute id is 'XYZ" on 21.01.2015. Maintained substitution period as 21.12.2014 to 31.01.2015. Workflow is standard shopping cart workflow in SRM system (WS40000014). Inside that there are two sub workflow calls, and the workitem task is TS40007953, which is maintained as general task, with no possible agents maintained.

What i noticed that, one workitem dated 23.12.2014 got forwarded automatically to XYZ, as it is falling under substitution period, but some new workitems created on 21.01.2015 are not visible in substitute UWL.

I have also checked SWI5 both users , Workitems are going to actual agent(ABC) but not visible in substitute(XYZ) inbox. they are not there in XYZ workload also(SWi5)

* task is maintained as general task

* Entry is there in HRUS_D2 table (Active)

* Substitution Active

* No possible agents maintained

* No excluded agent also.

**Rule used in task to find agent is 40000138 (Finding the actual agent correctly).

Just to mention one more thing, two program exits configured for this task( TS40007953)

/SAPSRM/CL_WF_DSET_EXIT

/SAPSRM/CL_WF_OFFLINEAPP_EXIT

With below code.

/SAPSRM/CL_WF_DSET_EXIT

METHOD if_swf_ifs_workitem_exit~event_raised.

DATA: lo_decisionset TYPE REF TO /sapsrm/cl_wf_dset_sbwf.

DATA: ls_wf_workitem TYPE /sapsrm/s_wf_workitem.

DATA: lv_ctime TYPE /sapsrm/wf_workitem_ctime.

DATA: lo_wi_context TYPE REF TO /sapsrm/cl_wf_wi_context.

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'BEGIN OF /SAPSRM/CL_WF_DSET_EXIT->IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED'

*----------------------------------------------------------------------*

FIELDS

im_event_name.

* Use helper class to access workitem context

CREATE OBJECT lo_wi_context

EXPORTING

io_context = im_workitem_context.

ls_wf_workitem-workitem_id = lo_wi_context->get_workitem_id( ).

* AFTER_CREATE -----------------------------------------------

IF im_event_name EQ if_swf_ifs_workitem_exit~C_EVTTYP_AFTER_CREATE.

TRY.

lo_decisionset = lo_wi_context->get_decisionset( ).

ls_wf_workitem-workitem_type = lo_wi_context->get_workitem_type( ).

CATCH cx_swf_cnt_container.

RAISE EXCEPTION TYPE cx_swf_ifs_workitem_exit_error.

ENDTRY.

* Check for correct work item type: It must be of type DECIDE

IF ls_wf_workitem-workitem_type NE /sapsrm/if_wf_process_c=>gc_workitem_type_decide.

RAISE EXCEPTION TYPE cx_swf_ifs_workitem_exit_error.

ENDIF.

* Get the creation timestamp

lv_ctime = /sapsrm/cl_wf_timestamp=>get_timestamp( ).

ls_wf_workitem-leading_object_guid = lo_decisionset->get_oid( ).

ls_wf_workitem-ctime = lv_ctime.

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'BEFORE /SAPSRM/CL_WF_PROCESS_MANAGER=>CREATE_WORKITEM'

*----------------------------------------------------------------------*

FIELDS

im_event_name

ls_wf_workitem-workitem_id

lv_ctime

ls_wf_workitem-leading_object_guid.

* Register the currently created work item for the decision set.

/sapsrm/cl_wf_process_manager=>create_workitem( ls_wf_workitem ).

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'AFTER /SAPSRM/CL_WF_PROCESS_MANAGER=>CREATE_WORKITEM'.

*----------------------------------------------------------------------*

* BEFORE_EXECUTION -----------------------------------------------

ELSEIF im_event_name EQ if_swf_ifs_workitem_exit~C_EVTTYP_BEFORE_EXECUTION.

* Set start time for SRM work item

* CAUTION: If the selection of the work item is not communicated to the SAP BWF (SRM inbox behavior)

* then the work item execution takes place with the storage of the decision data.

* AFTER_EXECUTION -----------------------------------------------

ELSEIF im_event_name EQ if_swf_ifs_workitem_exit~C_EVTTYP_AFTER_EXECUTION.

* Mark the SRM work item as executed

TRY.

" The only terminating event to be considered is 'EXECUTED'.

DATA lo_wi_container TYPE REF TO if_swf_ifs_parameter_container.

DATA lv_event_name TYPE char30.

lo_wi_container = im_workitem_context->get_wi_container( ).

" Get the 'terminating event'

" As this might be empty (use case 'system decision') the exception has to be caught silently.

TRY.

lo_wi_container->get(

EXPORTING

name = '_WI_COMP_EVENT_NAME'

IMPORTING

value = lv_event_name

).

IF lv_event_name EQ /sapsrm/if_wf_process_c=>GC_EVENT_OBSOLETE.

RETURN.

ENDIF.

CATCH cx_root. " EC NO_HANDLER

" Use case: System Decision

ENDTRY.

ls_wf_workitem-agent = lo_wi_context->get_agent( ).

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'BEFORE /SAPSRM/CL_WF_PROCESS_MANAGER=>COMPLETE_WORKITEM'

*----------------------------------------------------------------------*

FIELDS

ls_wf_workitem-workitem_id

ls_wf_workitem-agent.

/sapsrm/cl_wf_process_manager=>complete_workitem(

iv_workitem_id = ls_wf_workitem-workitem_id

iv_agent = ls_wf_workitem-agent ).

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'AFTER /SAPSRM/CL_WF_PROCESS_MANAGER=>COMPLETE_WORKITEM'.

*----------------------------------------------------------------------*

" register for COMMIT WORK as the SRM work item is completed now

im_workitem_context->do_commit_work( ).

CATCH cx_bo_error

cx_swf_cnt_container.

RAISE EXCEPTION TYPE cx_swf_ifs_workitem_exit_error.

ENDTRY.

* BEFORE_REMOVE -----------------------------------------------

ELSEIF im_event_name EQ if_swf_ifs_workitem_exit~C_EVTTYP_BEFORE_REMOVE.

* In case the work item is deleted, e.g. upon re-call,

* the SRM work item has to be updated.

ENDIF.

*----------------------------------------------------------------------*

LOG-POINT ID /sapsrm/wf_facade_sbwf SUBKEY 'END OF /SAPSRM/CL_WF_DSET_EXIT->IF_SWF_IFS_WORKITEM_EXIT~EVENT_RAISED'

*----------------------------------------------------------------------*

FIELDS

im_event_name.

ENDMETHOD.




/SAPSRM/CL_WF_OFFLINEAPP_EXIT, implementing IF_SWF_IFS_WORKITEM_EXIT


Below methods implemented

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

METHOD CONFIRM_WORK_ITEMS_SEND.

DATA lt_30_workitem_id TYPE TABLE OF /sapsrm/d_wf_030.

DATA lt_31_workitem_id TYPE TABLE OF /sapsrm/d_wf_031.

DATA ls_workitem_id LIKE LINE OF it_workitem_id. "#EC NEEDED

DATA ls_31_workitem_id LIKE LINE OF lt_31_workitem_id.

FIELD-SYMBOLS <fs_wi_in> LIKE LINE OF it_workitem_id.

FIELD-SYMBOLS <fs_30> LIKE LINE OF lt_30_workitem_id.

FIELD-SYMBOLS <lfs_range> TYPE ANY TABLE.

DATA lv_ctime TYPE /sapsrm/wf_workitem_ctime.

TYPES ty_range LIKE RANGE OF ls_workitem_id-wi_id." INITIAL SIZE 10.

data rt_range type ty_range.

DATA ls_range LIKE LINE OF rt_range.

DATA lt_scp_range TYPE ty_range.

ls_range-sign = 'I'.

ls_range-option = 'EQ'.

* ls_range-high = ''.

* build a range table

LOOP AT it_workitem_id ASSIGNING <fs_wi_in>.

ls_range-low = <fs_wi_in>-wi_id.

APPEND ls_range TO rt_range.

ENDLOOP.

* get the requested entries from th echange pointer table

SELECT * FROM /sapsrm/d_wf_030 INTO TABLE lt_30_workitem_id

WHERE WORKITEM_ID in rt_range.

* copy from change pointer to the to the send items table

lv_ctime = /sapsrm/cl_wf_timestamp=>get_timestamp( ).

LOOP AT lt_30_workitem_id ASSIGNING <fs_30>.

ls_31_workitem_id-WORKITEM_ID = <fs_30>-WORKITEM_ID.

ls_31_workitem_id-TIMESTMP = <fs_30>-TIMESTMP.

ls_31_workitem_id-TIMESTMP_SEND = lv_ctime.

append ls_31_workitem_id to lt_31_workitem_id.

ENDLOOP.

CALL FUNCTION '/SAPSRM/WF_CHGPT_S_MODIFY'

TABLES

it_wf_031 = lt_31_workitem_id.

* remove them from the changepointer table

ASSIGN rt_range TO <lfs_range>.

lt_scp_range = <lfs_range>.

CALL FUNCTION '/SAPSRM/WF_CHGPT_DELETE'

CHANGING

is_range = lt_scp_range.

ENDMETHOD.


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


METHOD if_swf_ifs_workitem_exit~event_raised.

DATA lv_ctime TYPE /sapsrm/wf_workitem_ctime.

DATA lo_wi_context TYPE REF TO /sapsrm/cl_wf_wi_context.

DATA ls_d_wf_030 TYPE /sapsrm/d_wf_030.

* DATA lv_workitem_id TYPE /sapsrm/d_wf_030-workitem_id.

TRY.

* Use helper class to access workitem context

CREATE OBJECT lo_wi_context

EXPORTING

io_context = im_workitem_context.

ls_d_wf_030-workitem_id = lo_wi_context->get_workitem_id( ).

lv_ctime = /sapsrm/cl_wf_timestamp=>get_timestamp( ).

ls_d_wf_030-timestmp = lv_ctime.

ls_d_wf_030-status = im_event_name.

CASE im_event_name.

* AFTER_CREATE -----------------------------------------------

WHEN if_swf_ifs_workitem_exit~c_evttyp_after_create. "'CREATED'

CALL FUNCTION '/SAPSRM/WF_CHGPT_MODIFY'

EXPORTING

is_wf_030 = ls_d_wf_030.

* STATE_CHANGED -----------------------------------------------

WHEN if_swf_ifs_workitem_exit~c_evttyp_state_changed. "'STATE_CHG'

CALL FUNCTION '/SAPSRM/WF_CHGPT_DELETE'

EXPORTING

iv_workitemid = ls_d_wf_030-workitem_id.

* AFTER_EXECUTION ---------------------------------------------

WHEN if_swf_ifs_workitem_exit~C_EVTTYP_AFTER_EXECUTION. "'AFT_EXEC'

CALL FUNCTION '/SAPSRM/WF_CHGPT_DELETE'

EXPORTING

iv_workitemid = ls_d_wf_030-workitem_id.

* AFTER_ACTION -----------------------------------------------

WHEN if_swf_ifs_workitem_exit~c_evttyp_after_action.

CALL FUNCTION '/SAPSRM/WF_CHGPT_MODIFY'

EXPORTING

is_wf_030 = ls_d_wf_030.

ENDCASE.

CALL FUNCTION '/SAPSRM/WF_CHGPT_GARBAGE_COLCT'.

CATCH cx_bo_error

cx_swf_cnt_container.

RAISE EXCEPTION TYPE cx_swf_ifs_workitem_exit_error.

ENDTRY.

ENDMETHOD.


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


METHOD GET_WORK_ITEMS_FFWD.

DATA ls_workitem_id LIKE LINE OF et_workitem_id.

DATA lt_workitem_id TYPE TABLE OF /sapsrm/d_wf_030.

FIELD-SYMBOLS <fs_workitem_id> LIKE LINE OF lt_workitem_id.

SELECT * FROM /sapsrm/d_wf_030 INTO TABLE lt_workitem_id

WHERE status = if_swf_ifs_workitem_exit~c_evttyp_after_action

ORDER BY workitem_id.

LOOP AT lt_workitem_id ASSIGNING <fs_workitem_id>.

ls_workitem_id-wi_id = <fs_workitem_id>-workitem_id.

APPEND ls_workitem_id TO et_workitem_id.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM et_workitem_id.

ENDMETHOD.


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


METHOD get_work_items_new.

DATA ls_workitem_id LIKE LINE OF et_workitem_id.

DATA lt_workitem_id TYPE TABLE OF /sapsrm/d_wf_030.

FIELD-SYMBOLS <fs_workitem_id> LIKE LINE OF lt_workitem_id.

SELECT * FROM /sapsrm/d_wf_030 INTO TABLE lt_workitem_id

WHERE status = if_swf_ifs_workitem_exit~c_evttyp_after_create

ORDER BY workitem_id.

LOOP AT lt_workitem_id ASSIGNING <fs_workitem_id>.

ls_workitem_id-wi_id = <fs_workitem_id>-workitem_id.

APPEND ls_workitem_id TO et_workitem_id.

ENDLOOP.

DELETE ADJACENT DUPLICATES FROM et_workitem_id.

ENDMETHOD.


--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------





Anybody having any idea why this may be happening.