Skip to Content
Author's profile photo Anas Abdulla

SAP Business Workflow: Function Modules, Transactions, Hints…

Hello SAPians,


Below are some handy function modules (along with sample code), transactions, programs & macros used in SAP Business Workflows. Also some important points to remember which I put together from my experience.

So here we go!!!

Function Modules

  1. Trigger Workflow FM – SAP_WAPI_CREATE_EVENT

What we need?

  • Business Object ( Eg. BUS2012  for Purchase Order Workflow)
  • Object Key (Eg. Purchase Order Number)
  • Event (Event to be triggered. Eg. RELEASED)
  • Input Container value (Optional, required only if you want to pass some mandatory value. Eg. Release Code in PO)

object_type     = ‘BUS2012’
object_key      = v_ebeln
event              = ‘RELEASED’
return_code     = lv_ret_code
input_container = lt_container.

Note: Mandatory parameters has to be passed via container


  1. Complete Workitem FM – SAP_WAPI_WORKITEM_COMPLETE

What we need?

  • WorkItem ID ( WorkItem ID of the decision step)
  • Container Value (To pass any value from program to workflow container)

workitem_id      = lv_wi_id
return_code      = lv_ret_code
simple_container = lt_container.


  1. Get All Workflow instances – SAP_WAPI_WORKITEMS_TO_OBJECT

What we need?

  • Business Object ( Eg. BUS2012  for Travel Request Workflow)
  • Object Key (It should be unique for each scenario. Eg. Travel Request Number)
  • If we pass the task number, we can get filtered information

objtype                  = ‘BUS2089’
objkey                   = lv_tripno
top_level_items          = ‘ ‘
selection_status_variant = 0004
text                     = ‘X’
language                 = sy-langu
determine_task_filter    = ‘X’
task_filter              = task
worklist                 = worklist.

Note: To get Workitem completion time, use table SWWLOGHIST by passing Workitem ID and METHOD (SWW_WI_STATUS_TO_COMPLETED).


  1. Read Workitem container – SAP_WAPI_READ_CONTAINER

What we need?

  • Workitem ID of the intance required

workitem_id      = lv_wi_id
language         = sy-langu
simple_container = lt_container.


  1. Read Workitem header – SWW_WI_HEADER_READ

wi_id     = wi_id
wi_header = ls_head.


  1. Check function module – SWE_TEMPLATE_CHECK_FB
  • This is a template which can be copied to a custom function module, to check the start condition of Workflow
  • This FM can be configured in Transaction SWE2


  1. Get User Inbox – RH_LOCAL_INBOX_GET

user_id            = lv_user_id
user_langu         = sy-langu
wi_list            = lt_workitem
task_filter        = lt_task_filter
user_cannot_get_wi = 1
OTHERS             = 2.

  1. Start Workflow without Event Linkage & BO – SAP_WAPI_START_WORKFLOW

task           = lv_workflow
do_commit      = ‘X’
user           = sy-uname
return_code    = lv_rc
workitem_id    = lv_wf_id
message_struct = lt_message_tab.

Important T-Codes

SWU3 – Workflow Customizing

SWDD, PFTC, PFAC – Workflow/Task Builder

SWEC, SWE2 – Event & event linkage

SWEINST – Instance Linkage

SWEQADM – Event Queue Administration (Make sure below dropdown (or 3 Do not change linkage) is selected)

SWDM – Workflow Explorer

SWPR – Restart Workflow after Error

SWPC – Restart Workflow after System Crash


SWELS, SWEL – Trace Events

SWUE – Trigger Event

SWI5 User Inbox

SWU_OBUF – Buffer Synchronization

SWF_GMP – Administrator Overview of workflows

SWU7 – Workflow Consistency Check

SWO1 – Business Object Builder

SWLO – Display work items for workflow object

SWI2_FREQ – Workitem Analysis (Workflow instances can be filtered based on task)

OOCU_RESP – Maintain rule with responsibilities

SWIA – Workflow processing as admin (Forward Workitem, complete manually, logically delete)

SWNADMIN – Extended Notification

Program (RSWUWFML2) – Send mail notification for Workitem

Program (RMPS_SET_SUBSTITUTE) – Substitution of Workitem agent (Admin)

SWFVISU – Task Visualization (For Webdynpro /BSP Approval Application)

Workitem ID will be available in Event Handler method (HANDLEDEFAULT) of the WDA Application Window.

Sample Code Below

DATA: loc_parameter      TYPE ihttpnvp,
loc_line_parameter TYPE tihttpnvp.

name  = if_wd_application=>all_url_parameters
value = loc_line_parameter ).

READ TABLE loc_line_parameter INTO loc_parameter WITH KEY name = ‘WI_ID’.

Frequently used macros in BO

SWC_GET_ELEMENT        – Eg.: swc_get_element container ‘WI_ID’ lv_id.

SWC_SET_ELEMENT         – Eg.: swc_set_element container ‘LOOP_COUNT’ lv_count.

SWC_GET_TABLE              –

SWC_SET_TABLE               –

SWC_CREATE_OBJECT     – Instantiate BO – swc_create_object lo_dms_doc ‘ZDMS_DOC’ lv_dms_key.



  • Maintain agent assignment – If you select attribute as ‘General Task’, Workitem will flow to all if no actual agent is found. So make sure you assign possible agents by not selecting General task. But remember, a Responsible agent can only process a work item if he is a possible agent and if he is not an excluded agent.
  • Refresh Organizational Environment in SBWP / run transaction SWU_OBUF if new agents are assigned to Workflows
  • Capture Event Linkages in customizing TRs
  • Always create new version when changing the existing workflow template
  • Check SM58 for WF-BATCH. Since all workflow tasks run in tRFCs then a crash will display an error there if the SWI1 error is not enough. (ST22 serves the purpose, but errors are stored only for 1 month or so based on basis setup)
  • In SM59, test the logical connection WORKFLOW_LOCAL_<client> to see if it can connect. This is the RFC destination that the workflow uses to submit tasks
  • Use SAP_WAPI*s instead of internal function modules (and tables)
  • Consider all possible terminating events – ‘Approved’, ‘Withdrawn’, ‘Changed’, ‘Deleted’ etc.
  • Set Workitem deadlines based on the factory calendar


Some Frequent Issues

  1. WF: Transported workflow template does not appear in the target system.

Reason: Changed version of the workflow is not generated properly in target system.

Solution: Run the Function Module SWD_WFD_REPLICATE_FROM_9999 in the target system by giving the import parameter as Workflow Template number.


  1. WF: New version doesn’t get picked during run time in the target system after transport.

Reason: The new version is not activated in the target system.

Solution: Activate the new version of the template using the program RSWDACTIVATE.

Assigned Tags

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

      "a handy GUIDE"?!?!? There was not GUIDE to it....just looks like a info dump. Would have been nice if you organized it better, explained what items are used for and "how" (like your functions dump), etc. This is of little use to anyone (new to WF or not).


      Author's profile photo Anas Abdulla
      Anas Abdulla
      Blog Post Author

      Hi Christopher,

      Thanks for your feedback. Being my first post, there is always room for improvement. I will be updating the blog to make it more useful based on your suggestions.



      Author's profile photo Hermann Ebert
      Hermann Ebert

      First off: Thanks Anas for the effort of putting all of this together / online!

      Regarding your post: I agree with Christopher. It's a lot of information and definitely useful, if used in the right context. My issue is: what is the context? 😉

      Therefore my proposal:

      • Rename it to "Workflow: Function Modules, Transactions, Hints"
      • Also add: What workflow are you talking about? I assume it's the SAP Business Workflow - add this to the title as well
      • Restructure the different parts using tables and more information
      • Alternatively split up the blog entry and make it a 3-series: How to implement a workflow in process xxx
        • Part 1: Process description & setup
        • Part 2: Implementation
        • Part 3: Troubleshooting


      Author's profile photo Anas Abdulla
      Anas Abdulla
      Blog Post Author

      Hi Hermann,

      Thanks for your feedback. Being my first post, there is always room for improvement.

      I will be updating the blog to make it more useful based on your suggestions.

      I have changed the title already (Thanks!).




      Author's profile photo Anjali Jain
      Anjali Jain


      Anas ,


      You helped me alot in creating my first complex workflow.


      Thank you so much

      Author's profile photo ayyappan venugopal
      ayyappan venugopal

      Thanks for sharing the useful information, it helps a lot..