Skip to Content
Author's profile photo Paul Bakker

Create a ‘Workflow Agents’ Report in 5 Simple Steps

This is the fifth instalment in the ambitious 73-part series ‘The Overworked Workflow Administrator’. In this episode, we contradict what we said earlier, by implementing a custom workflow report. But we think this one fills a much-needed gap.




SWI1 can be used to list workitems in READY status (i.e. those that no one has processed yet), but it doesn’t tell you whose inboxes they are in.


All you get is the alarming text ‘No Agent Available’.



Sure, you can drill down into each workitem separately and press the ‘Agents’ button, but our support staff would rather see all the agents listed in one report.


Something like this:



In this document, we create a report that has the same look and feel as SWI1, but this report also lists – for all dialog items in status ‘READY’ – the full list of users that have this item in their inbox.


Happily, all we need to do is copy a standard SAP program and make some minor adjustments.


Step 1. Copy the SAP report

SE38: Copy program RSWIWILS to ZRSWIWILS.




Activate the program. Then, in the attributes, change the title of the program to ‘Agents of Workitems’.


(If you see a message about “Different original and logon languages” then click on the “Change orig.language” button and continue to agree with whatever SAP asks you until you get to the “ABAP: Program Attributes ZRSWIWILS Change” window, where you can change the Title.)



Step 2. Create a new report transaction

SE93: Create a ‘report transaction’ ZWF_AGENTS and link it to program ZRSWIWILS.




Step 3. Edit the program

SE38: Make some simple code changes to ZRSWIWILS – see attached document.

(We simply add a call to SAP_WAPI_GET_WI_AGENTS to determine all current agents)

2017 UPDATE: The attachment has been lost, but I have added an explanation of the code changes at the bottom of this post.


Step 4.  Activate the program

(I told you these steps were simple )


Step 5.  Test the program


You can test it by running transaction ZWF_AGENTS. The selection screen is the one we are all familiar with:

But now, in the output listing, there are multiple lines for dialog workitems  that no one has processed yet.

Scroll along and you can see all the agents who currently have this workitem in their inbox.




Paul Bakker


PS If you are just getting into workflows, you may also like to read some of the previous instalments:


2017 EDIT: Summary of code changes.


SE38: Copy program RSWIWILS to ZRSWIWILS.
Copy all components, except Includes.
In the attributes, change the title to 'Agents of Workitems'.

SE93: Create transaction ZWF_AGENTS as a 'Report Transaction' (program and selection screen).
Transaction text = 'Agents of Workitems'
Selection Screen = 1000
Click 'SAPGUI for WIndows'.

SE38: Make the following simple code changes to ZRSWIWILS 

(1) At the beginning of the program

REPORT zrswiwils MESSAGE-ID swf_rep_base.
* This is a copy of program RSWIWILS, which underlies SWIA, 
* SWI1_USER etc.
* We have adapted it to provide an Agents report: list all current
* agents for a workitem. This reported is executed via transaction 
* Changes are marked with the text 'Agents'

(2)  about line 25

* DATA: g_report_name TYPE sy-repid VALUE 'RSWIWILS'.
DATA: g_report_name TYPE sy-repid VALUE 'ZRSWIWILS'.   "Agents

(3)  about line 56 - set the default values to only pick up 'READY' dialog workitems

    type   FOR swfawrkitm-wi_type default 'W',       "Agents - Dialog workitem
    state  FOR swfawrkitm-wi_stat default 'READY',   "Agents - Ready 

(4) about line 109 - set the title of the program
  ELSEIF tcode = 'SWIA_BATCH'.    "Context
    SET TITLEBAR '1006'.          "Context
  ELSEIF tcode = 'ZWF_AGENTS'.    "Agents
    SET TITLEBAR '1099'.          "Agents of Workitems
You also need to create the text element 1099 (double-click on it) and give it the value 'Agents of Workitems'. 
If you are asked to change the original language of the program, do so.

(5) about line 259 (after the call to 'get_workitem_header')

*-- begin Agents
* If the (dialog) workitem does not have an agent, then we want to
* list all current users who have this workitem in their inbox.
  if sy-tcode = 'ZWF_AGENTS'.
    PERFORM get_workitem_agents CHANGING g_wiheader.
*-- end Agents

(6) At the very end of the program, add this subroutine

*-- begin Agents
*       FORM get_workitem_agents                                *
* Augment the workitem list with agent information:
* if a DIALOG workitem is in status READY and has
* NO CURRENT AGENT, find all (responsible) agents
* who have this item in their inbox.
* Add one line to the list for each agent found.
*  <->  PT_WIHEADER                                             *
form get_workitem_agents changing pt_wiheader type swfatalvitm.

types: begin of ty_user_name,
         user type SYUNAME,
         name type AD_NAMTEXT,
       end of ty_user_name.
data: lt_user_names type sorted table of ty_user_name
                    with UNIQUE key user,
      ls_user_name type ty_user_name.

data: lt_wi_agents type SWRTWIAGENT,
      ls_wi_agents type SWR_WIAGENT,
      lt_wiheader type swfatalvitm,
      ls_wiheader type SWFAALVITM,
      lt_wi_ids type SWRTWIID,
      lv_user_id type XUBNAME,
      ls_user_address type ADDR3_VAL.

check pt_wiheader is not initial.

loop at pt_wiheader into ls_wiheader.
  clear: lt_wi_ids, lt_wi_agents.
* Dialog workitem in status READY with no agents?
  if ls_wiheader-wi_type EQ 'W' and         "dialog workitem
     ls_wiheader-WI_AAGENT is initial and   "no agents
     ls_wiheader-WI_STAT EQ 'READY'.         "ready
    append ls_wiheader-wi_id to lt_wi_ids.
* Get the current (responsible) agents, who would
* have the workitem in their inbox
*       LANGUAGE               = SY-LANGU
        WORKITEMS              = lt_wi_ids
*       USER                   = SY-UNAME
        WITH_SUBSTITUTES       = 'X'
*       RETURN_CODE            =
*       TIMESTAMP              =
        WI_AGENTS              = lt_wi_agents
*     TABLES
*       MESSAGE_LINES          =
*       MESSAGE_STRUCT         =
* For every agent found, add a new line to the WI list
    if lt_wi_agents[] is initial.
      "just add a line with no agent
      append ls_wiheader to lt_wiheader. 
      loop at lt_wi_agents into ls_wi_agents.  
        "add a new line for each agent
        ls_wiheader-wi_aagent = ls_wi_agents-user.
* get the user name
        clear ls_user_address.
        lv_user_id = ls_wi_agents-user.
* try a local buffer first
        read table lt_user_names into ls_user_name
           with key user = lv_user_id.
        if sy-subrc = 0.
          ls_wiheader-WI_AA_NAME = ls_user_name-name.
* get the user name from the user address
                    user_name              = lv_user_id
                    user_address           = ls_user_address
                    user_address_not_found = 1
                    OTHERS                 = 2.
          if sy-subrc = 0.
            ls_wiheader-WI_AA_NAME = ls_user_address-name_text.
* store in a buffer table
            clear ls_user_name.
            ls_user_name-user = lv_user_id.
            ls_user_name-name = ls_user_address-name_text.
            insert ls_user_name into table lt_user_names.
        append ls_wiheader to lt_wiheader.
        clear ls_wiheader-wi_aagent.
  else.  "if its not a dialog workitem, or already has an agent, 
         "just append it
    append ls_wiheader to lt_wiheader.

*Replace the original table with the extended table
if lt_wiheader[] is not initial.
  pt_wiheader[] = lt_wiheader[].
endform. "get_workitem_agents
*-- end Agents

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Rick Bakker
      Rick Bakker


      Author's profile photo Former Member
      Former Member

      Perfect......... 🙂


      Author's profile photo Anjan Paul
      Anjan Paul


      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author


      Author's profile photo Murali Krishna
      Murali Krishna

      Excellent Paul....

      Author's profile photo Arnab Das
      Arnab Das

      gr8 job ....

      Author's profile photo Former Member
      Former Member

      Thanks for sharing! 🙂

      Author's profile photo Susan Keohan
      Susan Keohan

      How did I not find this earlier?  Great job, Paul.  I have a new mission for the day - to implement this!

      I also wish SAP would deliver a report on workitems executed by substitutes.   What a pain that is.


      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      Thanks for the kind words Sue!

      So what is your requirement - to report on any substitute agents that have executed a dialog workitem? I've never heard that one before...?



      Author's profile photo Former Member
      Former Member

      Never though of this..Innovative...inspiring idea.. 😘



      Author's profile photo Shane Hong Sheng Tan
      Shane Hong Sheng Tan

      Good sharing.



      Author's profile photo Former Member
      Former Member

      This is nice but will not suffice the requirement where workitem is assigned to multiple users.



      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author


      I'm not sure what you mean.

      A workitem can only be 'assigned' to one person (ie reserved by that person), or assigned to no-one (because no-one has grabbed it yet; it may appear in multiple inboxes).

      The report above handles both cases.

      Or have I misunderstood?



      Author's profile photo Former Member
      Former Member

      Yaa you are right I missed some points on the arcticle.

      Related with susbstitution I think now the SAp Inbox has the Substitute for field that gets populated in the susbtituted SAP Inbox. We can build some logic like Paul build on the same way playing with table HRUS_D2



      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author


      If you are concerned about substitutes, the report already caters for them.

              WORKITEMS              = lt_wi_ids
              WITH_SUBSTITUTES       = 'X'                                <--------



      Author's profile photo Daniel Klein
      Daniel Klein

      Hi Paul,

      could you re-attach the document for the code in step 3? It seems it has been lost.

      Thanks and Regards

      Author's profile photo Former Member
      Former Member

      Must be a glitch. Please let us know when the document is back, or, is it as simple as just calling the function?

      Author's profile photo nitish chawla
      nitish chawla

      Could you please attach the document mentioned in step 3 again ?

      Author's profile photo Paul Bakker
      Paul Bakker
      Blog Post Author

      The document is lost forever (thank you very much, SCN migration :-), but I have now attached a note to the bottom of the post that explains the required code changes.