You will find here the different methods to extract the list of WorkItems by user and TaskID.
First we will start with the existing SAP Standard Function/BAPI to retrieve user’s WorkItems. Then we will have a look on Work Items and User tables in SAP Workflow.
Function/BAPI Retrieve Work Item by User
Count Work Items for User
Let’s start by counting the Work Items for a SAP User. You can use the function: SAP_WAPI_COUNT_WORKITEMS.
You should fill the user in USER and you can filter by Work Items, Task_Id.
Here the signature of SAP_WAPI_COUNT_WORKITEMS: Workflow Interfaces: Number of Work Items for User.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
FUNCTION sap_wapi_count_workitems. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *"Â Â IMPORTING *"Â Â Â Â VALUE(USER) LIKEÂ Â SY-UNAME DEFAULT SY-UNAME *"Â Â Â Â VALUE(DETAIL_LEVEL) LIKEÂ Â SWR_STRUCT-DETAILLV DEFAULT '0' *"Â Â Â Â VALUE(REFRESH_INTERVAL) LIKEÂ Â SWR_STRUCT-REFRESH DEFAULT 600 *"Â Â Â Â VALUE(LANGUAGE) TYPEÂ Â SYLANGU DEFAULT SY-LANGU *"Â Â Â Â VALUE(EXCLUDE_WORKITEMS_IN_ERROR) TYPEÂ Â XFELD DEFAULT SPACE *"Â Â EXPORTING *"Â Â Â Â VALUE(WI_COUNT) LIKEÂ Â SWR_WIPTS-WI_COUNT *"Â Â Â Â VALUE(RETURN_CODE) LIKEÂ Â SY-SUBRC *"Â Â TABLES *"Â Â Â Â Â Â WORKITEMS_PER_TASK STRUCTUREÂ Â SWR_WIPTS OPTIONAL *"Â Â Â Â Â Â TASK_FILTER_TABLE STRUCTUREÂ Â SWR_TSKFLT OPTIONAL *"Â Â Â Â Â Â MESSAGE_LINES STRUCTUREÂ Â SWR_MESSAG OPTIONAL *"Â Â Â Â Â Â MESSAGE_STRUCT STRUCTUREÂ Â SWR_MSTRUC OPTIONAL *"---------------------------------------------------------------------- |
Check this book about ABAP Development for SAP Business Workflow
SAP_WAPI_WORKITEMS_BY_TASK
The standard function module SAP_WAPI_WORKITEMS_BY_TASK is all what you need to extract list of Work Items for a SAP user.
You can filter by Time, User, Work Items Types (WORKITEM_TYPE_FILTER[]) and Task_ID (TASK_FILTER[]).
The Result will be in WORKLIST containing all relevant information for User’s Work Items.
Read also All you need to know about SAP SRM Confirmation TroubleShooting
Here the signature of SAP_WAPI_WORKITEMS_BY_TASK:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
FUNCTION sap_wapi_workitems_by_task. *"---------------------------------------------------------------------- *"*"Lokale Schnittstelle: *"Â Â IMPORTING *"Â Â Â Â VALUE(TIME) LIKEÂ Â SWR_TIMINT STRUCTUREÂ Â SWR_TIMINT *"Â Â Â Â VALUE(SELECTION_STATUS_VARIANT) LIKEÂ Â SWR_STRUCT-SELSTAVAR *"Â Â Â Â Â Â DEFAULT 0001 *"Â Â Â Â VALUE(TEXT) TYPEÂ Â XFELD OPTIONAL *"Â Â Â Â VALUE(LANGUAGE) TYPEÂ Â SYLANGU DEFAULT SY-LANGU *"Â Â Â Â VALUE(USER) TYPEÂ Â SYUNAME DEFAULT SY-UNAME *"Â Â EXPORTING *"Â Â Â Â VALUE(RETURN_CODE) LIKEÂ Â SY-SUBRC *"Â Â TABLES *"Â Â Â Â Â Â WORKITEM_TYPE_FILTER STRUCTUREÂ Â SWR_WITYPE OPTIONAL *"Â Â Â Â Â Â TASK_FILTER STRUCTUREÂ Â SWR_TASK OPTIONAL *"Â Â Â Â Â Â WORKLIST STRUCTUREÂ Â SWR_WIHDR OPTIONAL *"Â Â Â Â Â Â MESSAGE_LINES STRUCTUREÂ Â SWR_MESSAG OPTIONAL *"Â Â Â Â Â Â MESSAGE_STRUCT STRUCTUREÂ Â SWR_MSTRUC OPTIONAL *"---------------------------------------------------------------------- |
Work Items and User Related Tables
SAP Work Item Header Table SWWWIHEAD
SWWWIHEAD: Workflow Runtime: Header Table for All Work Item Types
You will find data such as :
Fields | SWWWIHEAD Table Fields |
---|---|
WI_ID | Â Work item ID |
WI_TYPE | Â Work item type |
WI_CREATOR | Â Creator of a work item |
WI_RH_TASK | Â Task ID |
WI_AAGENT | Â SWW_AAGENT |
SWFDEVENA | Activations for Event Linkages |
List of Current Work ITems assigned to a User : SWWUSERWI
SWWUSERWI:Â Current Work Items Assigned to a User.
The fields of SWWUSERWI are:
Fields | SWWUSERWI Tables Fields |
---|---|
USER_ID |  User Name in User Master Record |
WI_ID | Â Work item IDÂ |
TASK_OBJ | Â Concatenation of Object Type and Object IDÂ |
NO_SEL |  Indicator Entry has no Relevance to Selection |
NO_EXECUTE |  Work Item May Not be Executed by User Specified |
FORWARD |  Indicator Work Item was Forwarded |
Assignment of WIs to Org. Unit/Task: SWWORGTASK
SWWORGTASK:Workflow Runtime: Assignment of WIs to Org. Unit/Task
You can use this table if you want retrieve the list of Work Items by an Organization Unit rather than SAP User.
Fields | Main SWWORGTASK Fields |
---|---|
WI_ID | Work item IDÂ |
ORG_OBJ | Concatenated Identification (Type and ID) of Org.Objects |
TASK_OBJ | Task |
IDNO_SEL | Indicator Entry has no Relevance to Selection |
FORWARD |  Indicator Work Item was Forwarded |
Note that you can use directly the SAP Transaction code SWI5.
The Tcode SWI5 offers filtering Work Items by : Org. Unit, Type ( Completed Work Items, To Be Completed WI), Date, Task, Task Group and Application Component.
Check also The Most important SAP Workflow Transactions List
SAP Work Item History Table: SWWLOGHIST
SWWLOGHIST: Workflow Runtime: History of a Work Item
In the SAP Work Item History Tables, you will find all the information you need.
Check the following fields:
- WI_ID :Â Work item ID
- METH_USER:Â Actual Agent of Work Item