How to retrieve List of WorkItems for a user ?

List of WorkItems for a User

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.

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:

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 :

FieldsSWWWIHEAD Table Fields
WI_IDWork item ID
WI_TYPEWork item type
WI_CREATORCreator of a work item
WI_RH_TASKTask ID
WI_AAGENTSWW_AAGENT
SWFDEVENAActivations 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:

FieldsSWWUSERWI Tables Fields
USER_IDUser Name in User Master Record
WI_IDWork item ID
TASK_OBJConcatenation of Object Type and Object ID
NO_SELIndicator Entry has no Relevance to Selection
NO_EXECUTEWork Item May Not be Executed by User Specified
FORWARDIndicator 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.

FieldsMain SWWORGTASK Fields
WI_IDWork item ID
ORG_OBJConcatenated Identification (Type and ID) of Org.Objects
TASK_OBJTask
IDNO_SELIndicator Entry has no Relevance to Selection
FORWARDIndicator 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 alsoThe 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