Skip to Content
Technical Articles
Author's profile photo Jose Sequeira

Workflow – Relate WF Instances of a specific BOR (Purchase Requisition item example)


As you may know, the SAP_WAPI* function modules are one of the best “toolkits” a Workflow developer can have. Just to mention a few:

SAP_WAPI_CREATE_EVENT                 = Create Events;

SAP_WAPI_DECISION_COMPLETE      = “Automate WF decision”;

SAP_WAPI_CREATE_WORKLIST          = Check out someones WF Inbox;

etc, etc, etc…

But today, i’m here to explore a special one, the SAP_WAPI_WORKITEMS_TO_OBJECT one. What does it do? It “relates” a BOR object with all the Workflows instances that exists for it (without errors). Both 2 good examples of use case would be PR and PO WFs, as you may know for every code (assuming that you are using standard WFs) on the release strategy process, it generates a separated WF instance.

Example: Based on the strategy below, for each code approval (E1, E2, E3 and E4) a WF will be created (total 4 WFs):

So what if you need something in every WF instance of that PR or PO? How could you relate every WF ID? It’s here that the SAP_WAPI_WORKITEMS_TO_OBJECT comes in! Based on the BOR and the instance, it will list all WF IDs.

Below i’ve done a simple report to demonstrate the use of it (for PR, Purchase Requisition item WFs – BUS2012):

*& Report  ZPRITEM_WFS

report  zpritem_wfs.

data: gr_table type ref to cl_salv_table.

data: lt_worklist type table of swr_wihdr,
      ls_object   type sibflporb,
      ls_key      type swotobjid-objkey.

selection-screen begin of block b1 with frame title text-001.
parameters: p_banfn type banfn obligatory,
            p_bnfpo type bnfpo obligatory.
selection-screen end of block b1.


  "Getting stuff ready...
  concatenate p_banfn p_bnfpo into
  concatenate p_banfn p_bnfpo into
  ls_object-typeid = 'BUS2009'."PR Bor...
  ls_object-catid  = 'BO'."For Bor...

      object_por = ls_object
      objtype    = 'BUS2009'"Here you could swith BORs...
      objkey     = ls_key
      worklist   = lt_worklist.
  if lt_worklist[] is initial.
    message 'No luck...' type 'S' display like 'E'.
    "Show ALV...
    cl_salv_table=>factory( importing r_salv_table = gr_table changing t_table = lt_worklist ).
    gr_table->display( ).

So if you put a PR/Item, you’ll get a list like these:

Now with this powerful function module, you could explore all kinds of use cases, such as FIORI Apps for WF history, reports, etc.

Don’t know what BORs are and how to find the correct one for you case? Check here for more details and transaction SWO3 for a list of BORs based on application components.



Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rashid Javed
      Rashid Javed

      Thanks a lot for this useful info. I wish i had known this before so that i could avoid searching work item titles for specific number patterns 🙂