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: 
gaurang_gujar
Active Participant
0 Kudos
3,113
How to Create a Custom Workflow Report in SAP

In my previous blog:  https://blogs.sap.com/2013/09/01/workflow-administartive-tool/, I talked about how to use the SAP Workflow Admin Tool to reduce support costs. In this blog, I will show you how to create a custom workflow report.

Step 1: Identify the workflow template number.

The first step is to identify the workflow template number for the workflow you want to track. This number is usually in the format WSXXXXXXX. For custom workflows, the number will start with WS9XXXXXXX.

Step 2: Get the instance key.

The next step is to get the instance key for the workflow. The instance key is a unique identifier for the workflow instance. For example, the instance key for a purchase order workflow would be the purchase order number.

Step 3: Get the TOPWID.

Once you have the instance key, you can use the SWW_WI2OBJ table to get the TOPWID. The TOPWID is the runtime workitem id for the main workflow instance. you will need to pass the relevant business object in field  CATID as 'BO' for Business Object , Type ID as  Business Object e.g. BUS2012 for Purchase order and  Instance Key in INSTID field.

Step 4: Get the status.

You can use the SWWWIHEAD table to get the status of the workflow. The status will be one of the following:

  • Error: The workflow is in error.

  • Completed: The workflow is completed.

  • Cancelled: The workflow is cancelled.


Step 5: Determine if the workflow is approved or rejected.

If the status is "Completed", you can use the following methods to determine if the workflow is approved or rejected:

  • Use the transactional data. For example, if the workflow is a park to post invoice workflow, you can check if the invoice is posted. If the invoice is posted, then the workflow was approved.

  • Use WAPI. You can use the SAP_WAPI_READ_CONTAINER WAPI to read the rejection comments. If there are rejection comments, then the workflow was rejected.


Step 6: Get the approver.

If the workflow is completed, you can use the SWWIHEAD table to get the approver. The approver is the user who approved or rejected the workflow.

Step 7: Handle incomplete workflows.

If the workflow is not completed, there are two possible cases:

  • The dialog workitem is in the "Ready" status. This means that the workflow is waiting for an approver. You can use the SWWUSERWI table to get a list of possible approvers.

  • All the dialog workitems are completed, but the TOPWID is still in the "In Progress" status. This means that the workflow is in a hung state.


 

Conclusion

This blog post has shown you how to create a custom workflow report in SAP. This report can be used to track the status of workflows, identify approvers, and handle incomplete workflows.

I hope you found this blog post helpful. If you have any questions, please feel free to leave a comment below.

Stay tuned for my next blog post, where I will talk about how I reduced my workflow support costs.

 
Labels in this area