Hi Carlos
You need to define the FM in the same way as that of SWX_GET_MANAGER and use in the rule.
I am not sure which part is still causing an issue at your end; hence was motivated to to try this myself. Here are some screen shots and the code to help you...just pickup the ones for which you are not clear about...
Hope this helps.
regards,
Modak
Sample Table Design (I have kept the same name as given by you)
Rule Design:
* "Terminate if Rule Resolution Without Result" will make the WF go in error if no agents are found (and that is the right way)
Rule Usage:
Outcome:
FM Design:
FM Code:
FUNCTION z_get_approver.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOBODY_FOUND
*"----------------------------------------------------------------------
* Necessary Macros for reading the container AC_CONTAINER
INCLUDE <cntain>.
TYPES: BEGIN OF lty_approvers,
approver_id TYPE xubname,
END OF lty_approvers.
DATA: lv_wf_id TYPE sww_task,
lv_task_id TYPE sww_task,
ls_approver TYPE lty_approvers,
ls_actor TYPE swhactor,
lt_approvers TYPE TABLE OF lty_approvers.
REFRESH: actor_tab.
* Get the Workflow Number
swc_get_element ac_container 'WF_ID' lv_wf_id.
* Get the oTask Number
swc_get_element ac_container 'TASK_ID' lv_task_id.
* Exit if necessary data is not supplied
CHECK lv_wf_id IS NOT INITIAL AND
lv_task_id IS NOT INITIAL.
* Get all approvers based on the WF and Task Numbers
SELECT approver_id
INTO TABLE lt_approvers
FROM zhsp_wf_hgs_apr
WHERE wf_id = lv_wf_id
AND task_id = lv_task_id.
* Raise Exception if no approver is available
IF sy-subrc NE 0 OR lt_approvers IS INITIAL.
RAISE nobody_found.
ENDIF.
* Set Object type to US - User as approvers .... user IDs maintained in table zhsp_wf_hgs_apr
ls_actor-otype = 'US'.
* Assign data to Actor tab
LOOP AT lt_approvers INTO ls_approver.
CLEAR ls_actor-objid.
MOVE ls_approver-approver_id TO ls_actor-objid.
APPEND ls_actor TO actor_tab.
ENDLOOP.
ENDFUNCTION.
Let's see if this helps you