SAP Virtual/Onsite Trainings

Document Categories:

What's New?

Contribute?

Sample Specs

What's Hot?

Web Dynpro for ABAP Tutorials 


Join the Mailing List
Enter name and email address below:
Name:
Email:
Subscribe  Unsubscribe 

Program Exits in Work Item for Workflow

By Anirban Bhattacharjee, KPIT Cummins and Infosystems

Purpose: The purpose of this document is to demonstrate how to use Program Exits in a Work Item for Workflow.

Business Scenario: Many times we have scenarios where we want to do some additional custom processing when a work item is created or executed. 

SAP has given us a way by which we can design Program Exits in a work item. The events on which we can program this are mentioned below

  • Before Work Item Creation

  • After Work Item Creation

  • Before Work Item Execution

  •  After Work Item Execution

  • After the execution of a Synchronous Object Method in the work item

  • Before Physical Deletion of the Work Item

  • On the Status Change of a Work Item

  • On a Rule execution in the Work Item

  • After an action execution in the Work Item

  • Before and action execution in the Work Item

We will see that the class we will model later on in this tutorial will contain the methods that can be implemented for handling the above events.

Here we will send e-mail via this Program Exit once when a work item is created and once when it is executed.

There will be no e-mail steps modeled in the workflow. They will happen solely from the program exit.

Process to design the Program Exit in a Work Item

Let us look at the tab in a work item where this exit is designed

Note that the SAP Documentation states that the class that will be modeled here must support the IF_SWF_IFS_WORKITEM_EXIT interface. Please ensure that inside this class we will not be using any ABAP Instruction that can release the current LUW like COMMIT WORK, ROLLBACK WORK or using RFC Function Calls.

Now we will design a class via the transaction SE24. We will call this class ZZCL_WORK_ITEM_EXIT.

The Properties tab of the class will look as shown. We will add the type group SWRCO

We will now declare the interface IF_SWF_IFS_WORKITEM_EXIT in the interface tab

Once we declare the interface, the attributes related to this interface will appear in the Attributes Tab.

Notice the events that can happen with a work item in the Description column. This is what was mentioned at the start of the tutorial.

We will now add a couple of custom attributes as mentioned below:

WI_CONTEXT as a type reference to IF_WAPI_WORKITEM_CONTEXT; this interface returns the various attributes of a work item.

Displaying this interface via SE24 and showing you the methods

To see how to implement these methods in a class, please refer CL_SWF_RUN_WORKITEM_CONTEXT.

This class is very helpful to understand how to do various operations on a work item.

The other custom attribute will be named PROCESS_STATUS. This will contain a default value ‘sap.bc.bmt.wfm.process.status’.

The attributes tab now looks like as shown below

Both the attributes are Instance Attribute and Private visibility.

Now let us navigate to the Methods Tab of this class.

The only method created by default is EVENT_RAISED. This will be called whenever the Work Item Events (mentioned at the start of the tutorial) are triggered.

The parameters that appear in this method are

(Note that there is a parameter IM_WORKITEM_CONTEXT which refers interface IF_WAPI_WORKITEM_CONTEXT)

Now we will create two more methods called AFTER_WI_CREATION and AFTER_WI_EXECUTION as shown.

Both the methods are Instance Method with Private Visibility.

Click here to continue..

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image