Skip to Content
Author's profile photo Ronen Weisz

Workflow reporting in BW – extractor improvements

When starting to work with the BI team on creating workflow reports, you will usually find that although the standard extractors make a lot of data available, there are a few things missing that you will need in order to make the data useful.

The first missing part of the puzzle is the active workitems. ‘surprisingly’ most customers don’t accept a “not reserved by an agent” for almost all active workitems as a good display of the workflow status in the organization…   so you need to give the BI team a way to see the workitems agents and a SAP_WAPI_GET_WI_AGENTS needs to be added to the extractor, although reading from the SWWUSERWI table will work just the same, this is less recommended to read directly from the workitem tables  and as you see in the next paragraphs you will use more calls to function modules that will slow you down anyway.

Another missing part is the workitem result; some reports are made to see the amounts of rejected workitems. This has two problems you will have to deal with:

The first:  you will need to add the ‘_WI_RESULT’ container element by using the SAP_WAPI_READ_CONTAINER function module and SAP_WAPI_DECISION_READ to get the possible decisions.  Combine that with the actual result to see the decision text (although you would expect a WAPI called ‘decision read’ will give you the decision itself…).

The second problem is that result ‘0001’ is usually approve and ‘0002’ is usually reject but, you can’t depend on that since there are always exceptions to the rule, you will probably need a z-table telling the BW what is reject and approve in different workflows.

The last part of the puzzle is that customers want to see reports by the station on the way to approval and this is usually more detailed then the task number because the same task can be used by different approvers, for example in a release strategy based purchasing workflow the same task will be used by Buyers, FI, CEO etc. and reports are usually asked in this detail. The solution I use for this is to transfer the release code to the task container; even in tasks not based on release strategy I sometime transfer an approver code to the task container to help identify the approval station. Again you have to read the release code transferred to the workitem by the SAP_WAPI_CONTAINER_READ function module.

Even if the workflow task wasn’t built with a approver code in its container the data is usually in the workflow (top_wi_id) container but this will be less generic to extract. Another way to get the station is the location of the task in the workflow (the workflow node) if useable and the task. 

So you will end up with a table that is based on workflow-task-node-release code = approval code to determine the approval station. Pay attention that a buyer might be with a different approver code in different workflows. So this 5-th field is needed. Also because the workflow has version management, you might need more than one entry for an approver if the approval task was moved in the workflow structure.

Assigned Tags

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

      Good stuff! And then you are not even touching on run times which opens a whole new can of worms.

      Author's profile photo Ronen Weisz
      Ronen Weisz
      Blog Post Author

      Thanks, I had less trouble with run times since the basic data of creation & completion date and time are delivered by the standard extractors Although SLA (service level agreement) times for tasks/workflows/objects might be a good addition.

      Author's profile photo andrew curtis
      andrew curtis

      'can of worms' is exactly how I feel about it.  trying to interpret the technical Wf information into terms a functional consultant understands and then the same for a BW consultant who wants to apply their 'BW Extractor way of doing things'. Can of worms 🙂

      Author's profile photo Former Member
      Former Member

      Hi Ronen

           Your post is really helpful . We are in the process of implementing BW reports for Purchase Requisition Workflow . I did a quick search on the standard extractors in our system but could not find the 0BPM_LOGHIST , 0BPM_WIHEAD and all related to them . Could you please point out to me where I can get the information to get these extractors in our system .Just to add we do not have SRM module.

      Any help is sincerely appreciated



      Author's profile photo Ronen Weisz
      Ronen Weisz
      Blog Post Author
      Author's profile photo Former Member
      Former Member



      Thanks for your input, it was useful.

      However, I think it might be interesting to know, that SAP provides functions to get the titles linked to decisions. No need to create a Z table to do that.

      Hereunder, you'll find a code that can help if neede:


      Function to retrieve the title of the work item:


      call function 'SWU_GET_DECISION_TEXT_TITLE'
      wiid               = wi_id à is WORKITEMID stored within the SWL entry.
      decision_title     = title_text à char132 field
      decision_text= lt_textàlt_text type swd_text_d occurs 5 with header line.
      node_not_found     = 1
      text_not_found     = 2
      workflow_not_found = 3
      others             = 4.
      if sy-subrc <> 0.
      *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.


      Using this we retrieved a table containing the decision texts and alternative and the work item title.

      Now we need to retrieve the description:


      A little form can be used:

      *&      Form  get_task_description
      *       text
      *      -->VALUE(WI_ID)   text
      *      -->WI_WLC_HEADER  text
      *      -->LINEWIDTH      text
      form get_task_description using value(wi_id)  like swwwihead-wi_id
      wi_wlc_header like swwwlhead
      linewidth     like thead-tdlinesize.
      * begin of local data definition
      data:  l_task like rhobjects-object,
      t_text_lines like tline occurs 0 with header line.
      * end of local data definition

      *- initialize global data
      clear task_description_text.
      refresh task_description_text.

      *- get header data
      call function 'SWW_WI_WL_READ'
      wi_id         = wi_id
      wi_wlc_header = wi_wlc_header
      read_failed   = 01.
      check sy-subrc eq 0.

      *- get task description and replace parameters
      l_task = wi_wlc_header-wi_rh_task.
      call function 'SWU_GET_TASK_TEXTLINES'
      task              = l_task
      wi_id             = wi_id
      usage             = wi_wlc_header-wi_type
      linewidth         = linewidth
      ascii_text_lines  = t_text_lines
      wrong_usage       = 01
      text_not_found    = 02
      text_system_error = 03.
      if sy-subrc ne 0.
      refresh t_text_lines.
      t_text_lines-tdline = 'Keine Beschreibung vorhanden'(003).
      append t_text_lines.

      *- set global data
      loop at t_text_lines.
      task_description_text-descript = t_text_lines-tdline.
      append  task_description_text.

      endform.                               " GET_TASK_DESCRIPTION