Sometimes you need to find out whom a particulat workflow task belongs to or other way, which workflow tasks belong to a specific user.
Tasks of a specific user
To find out pending tasks of a specific user you can simply read table SWWUSERWI passing USER_ID as a parameter.
Another method is calling a method RH_LOCAL_INBOX_GET with parameters USER_ID, USER_LANGU and READ_OTYPE (this is to determine an Org.structure type – for user it will be ‘US’)
Who is responsible for a specific task
For example let’s assume we have a workflow with name WS90100079 and there is a “Decision task” in this workflow with name TS90100211.
A new instance of this workflow has been started with key (instance ID) ‘ABCD123456’.
Now we need to find out in our program the agent responsible for processing this task…how to do it?
- We need to get the first workitem ID of the workflow instance:
SELECT SINGLE top_wi_id INTO lv_top_wiid FROM sww_wi2obj WHERE instid = 'ABCD123456' AND wi_rh_task = 'WS90100079'.
- We need to get the workitem ID of the Decision task TS90100211 in our workflow instance (we get it by linking via lv_top_wiid from previous step)
SELECT SINGLE wi_id INTO lv_wiid FROM swwwihead WHERE wi_chckwi = lv_top_wiid.
- We will get the user(s) responsible for processing the workitem we got in step 2 … there might be more users responsible and all such users will be listed.
SELECT user_idINTO TABLE lt_userid FROM swwuserwi WHERE wi_id = lv_wiid.
Or we can do it in one joined SELECT command:
SELECT u~user_id INTO lt_userid "#EC CI_NOFIRST FROM sww_wi2obj AS o JOIN swwwihead AS h ON o~top_wi_id = h~wi_chckwi JOIN swwuserwi AS u ON u~wi_id = h~wi_id WHERE o~wi_rh_task = 'WS90100079' AND o~instid = me->mv_objkey AND h~wi_rh_task = 'TS90100211'.