Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
jose_sequeira
Active Participant
1,654
Hello,

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.

start-of-selection.

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

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

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.

Enjoy.

Regards.
1 Comment
Labels in this area