Skip to Content
0
Former Member
Mar 13, 2013 at 10:31 AM

WORK ITEM SEND TO ALL USER IDs IN ZTABLE USIN RULE AGENT DETERMINATION

60 Views

Hi All,

I have custom table with the above fields Client ,Cost Center user id 1, user id 2, user id 3, user id 4, user id 5

Based on the cost center i have created a function module rule to determine agent user ids .I am using Rule to determine agent in my workflow.

I dont understand why everytime i run the workflow it sends work item to all users in the Ztable but not to the specific userid .

This are two different function module rules for userd1 and userid 2 respectively.

What could be the problem,PLEASE HELP?


See the code for first approver.

FUNCTION zfm_getapprover_res.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" TABLES

*" AC_CONTAINER STRUCTURE SWCONT

*" ACTOR_TAB STRUCTURE SWHACTOR

*" EXCEPTIONS

*" APPROVER_NOT_FOUND

*"----------------------------------------------------------------------

INCLUDE <cntn01>.

DATA: verak_user TYPE verak_user,

wa_actor TYPE swhactor ,

num_lines TYPE i,

lv_kostl TYPE kostl.

swc_get_element ac_container 'KOSTL' lv_kostl.

IF sy-subrc = 0.

REFRESH actor_tab.

CLEAR verak_user.

SELECT SINGLE zuserid1 FROM zres_approvers INTO verak_user

WHERE kostl = lv_kostl.

IF sy-subrc = 0.

CLEAR: wa_actor, actor_tab.

wa_actor-otype = 'US'.

wa_actor-objid = verak_user .

APPEND wa_actor TO actor_tab.

CLEAR wa_actor.

ENDIF.

DESCRIBE TABLE actor_tab LINES num_lines.

IF num_lines IS INITIAL.

RAISE approver_not_found.

ENDIF.

ENDIF.

ENDFUNCTION.

See rule 2 function module for approver2

FUNCTION zfm_getapprover_res.

*"----------------------------------------------------------------------

*"*"Local Interface:

*" TABLES

*" AC_CONTAINER STRUCTURE SWCONT

*" ACTOR_TAB STRUCTURE SWHACTOR

*" EXCEPTIONS

*" APPROVER_NOT_FOUND

*"----------------------------------------------------------------------

INCLUDE <cntn01>.

DATA: verak_user TYPE verak_user,

wa_actor TYPE swhactor ,

num_lines TYPE i,

lv_kostl TYPE kostl.

swc_get_element ac_container 'KOSTL' lv_kostl.

IF sy-subrc = 0.

REFRESH actor_tab.

CLEAR verak_user.

SELECT SINGLE zuserid2 FROM zres_approvers INTO verak_user

WHERE kostl = lv_kostl.

IF sy-subrc = 0.

CLEAR: wa_actor, actor_tab.

wa_actor-otype = 'US'.

wa_actor-objid = verak_user .

APPEND wa_actor TO actor_tab.

CLEAR wa_actor.

ENDIF.

DESCRIBE TABLE actor_tab LINES num_lines.

IF num_lines IS INITIAL.

RAISE approver_not_found.

ENDIF.

ENDIF.

ENDFUNCTION.