Workflow in SAP: classic and flexible
How SAP routes work to people: tasks, agents and events. Classic workflow with the Workflow Builder, flexible workflow in S/4HANA, how to start it from ABAP and how to administer it.
- Sections
- 9
- Reviewed
- November 2026
- Sources
- 4 links
What workflow is
A workflow delivers each piece of work, in the right order, to the person who has to do it, with the information they need. The typical example is an approval: a purchase order is created, the system sends it to the person responsible, who approves or rejects it, and the process continues one way or the other.
The work is split into tasks. Each time the workflow reaches a task it creates a work item and sends it to the inbox of the agents who must do it. Workflows usually start with an event, such as "order created" or "invoice blocked".
| Type | Where | Who configures it | Tool |
|---|---|---|---|
| Classic workflow (SAP Business Workflow) | ECC and S/4HANA on-premise | The technical team | Workflow Builder (SWDD) |
| Flexible workflow | S/4HANA (on-premise and cloud) | The process expert, without coding | Fiori app Manage Workflows (F2190) |
| SAP Build Process Automation | SAP BTP | The process expert or the technical team | Visual editor in the cloud |
Flexible workflow uses the same engine as classic workflow underneath: the work items are the same and they look the same in SWI1. What changes is who defines the process and how.
The basic concepts
| Concept | What it is |
|---|---|
| Workflow template (WS) | The definition of the process: its steps, conditions and loops. Created in the Workflow Builder (SWDD) |
| Standard task (TS) | A specific piece of work, which usually runs a method of an object (for example, "approve order"). Maintained in PFTC |
| Work item | Each execution of a task. It is what the user sees in their inbox |
| Business object | The object the workflow works on: a BOR type (SWO1), such as BUS2012 for the purchase order, or an ABAP class with the IF_WORKFLOW interface |
| Event | A notice that something has happened to an object ("CREATED", "RELEASED"…). It can start a workflow or end a task that is waiting for it |
| Container | The variables of the workflow and of each task |
| Binding | How data passes from one container to another: from the event to the workflow, from the workflow to the task and back |
| Agents | The users who receive the work item. There are possible agents (they can do it), responsible agents (chosen among them) and excluded agents |
| Agent determination | The rule that decides who receives the work item: a user, a position in the organizational structure, a rule with responsibilities (OOCU_RESP) or a function |
Preparing the system
Before using workflows in a client you have to do their basic setup. Transaction SWU3 (automatic workflow customizing) checks it and does almost all of it by itself: it shows each point in green or red.
- Run SWU3 and click "Perform automatic workflow customizing". An administrator with the right authorizations does this.
- Check the RFC destination WORKFLOW_LOCAL_<client> in SM59: it is the connection the system uses to run the workflow steps.
- Check that the system user WF-BATCH exists; background steps run with it.
- Test that everything works with the sample workflow that SWU3 itself offers.
In S/4HANA, flexible workflow also needs the scenarios of each area (purchasing, supplier invoices…) to be activated, and the My Inbox app (F0862) to be set up; that is where users receive their tasks.
A classic workflow with the Workflow Builder
The Workflow Builder (SWDD) draws the process as a diagram of steps. These are the most used:
| Step | What it is for |
|---|---|
| Activity | Runs a task: a method of the object, in dialog (a person does it) or in the background |
| User decision | Asks the agent and continues down the branch they choose: "Approve" or "Reject" |
| Condition and multiple condition | Chooses the path according to the data (for example, the order amount) |
| Loop | Repeats steps until a condition is met |
| Send mail | Sends a notice by e-mail |
| Wait for event | Stops the workflow until an event arrives |
| Fork | Several branches in parallel; the workflow continues when the required ones finish |
- In SWO1 choose the business object (or create a Z subtype if you need your own method or event). In new code you can use an ABAP class with the IF_WORKFLOW interface.
- In PFTC create the standard tasks: the method they run, their possible agents and their terminating events.
- In SWDD create the template: the container, the steps and the agent determination of each one.
- In the basic data of the template set the triggering event and its binding, and activate the linkage (it is also shown in SWE2).
- Activate the template and test it with SWUS (start a workflow) or by raising the event with SWUE.
When you change a workflow that is already in use, create a new version: running workflows continue with the version they started with.
Starting a workflow from ABAP
The recommended way is to raise an event and let the event linkage start the workflow: the program does not depend on the workflow, and the workflow can be switched on or off without touching the code. For a BOR object, use the function SAP_WAPI_CREATE_EVENT:
DATA lt_contenedor TYPE STANDARD TABLE OF swr_cont WITH EMPTY KEY.
DATA lv_retorno TYPE sy-subrc.
" Data the workflow needs (optional)
lt_contenedor = VALUE #( ( element = 'RELEASECODE' value = lv_codigo_liberacion ) ).
CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
EXPORTING
object_type = 'BUS2012' " purchase order
object_key = lv_ebeln
event = 'RELEASED'
IMPORTING
return_code = lv_retorno
TABLES
input_container = lt_contenedor.
IF lv_retorno <> 0.
MESSAGE 'The event could not be raised' TYPE 'E'.
ENDIF.If the object is an ABAP class with the IF_WORKFLOW interface, the event is declared in the class and raised with CL_SWF_EVT_EVENT=>RAISE, stating that the object type is a class:
TRY.
cl_swf_evt_event=>raise(
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl " ABAP class (BOR: mc_objcateg_bor)
im_objtype = 'ZCL_WF_SOLICITUD'
im_event = 'APROBADA'
im_objkey = CONV #( lv_id_solicitud ) ).
COMMIT WORK. " the event is raised on commit
CATCH cx_swf_evt_invalid_objtype cx_swf_evt_invalid_event INTO DATA(lx_error).
MESSAGE lx_error TYPE 'E'.
ENDTRY.| Function | What it is for |
|---|---|
SAP_WAPI_START_WORKFLOW | Starts a template directly, without an event |
SAP_WAPI_WORKITEM_COMPLETE | Completes a work item from a program |
SAP_WAPI_READ_CONTAINER | Reads the container of a work item |
SAP_WAPI_WORKITEMS_TO_OBJECT | Lists the workflows and work items of an object (for example, of an order) |
Use the SAP_WAPI_* functions, which are the interface meant for customers, not the internal workflow functions and tables. They replace old functions such as SWE_EVENT_CREATE.
Flexible workflow in S/4HANA
In S/4HANA, SAP changed the approach: the workflow is no longer defined by the technical team but by the process expert, in a Fiori app. Instead of one big workflow with many branches, you create several small workflows, each with its own start condition.
| Piece | What it is |
|---|---|
| Scenario | The set of pieces that can be used: tasks, agent rules and conditions. SAP delivers them for each process; on-premise you can also create your own (SWDD_SCENARIO) |
| Manage Workflows (F2190) | The app where the workflows of a scenario are created: start condition, steps, agents and order. Each area has its own version of the app (purchase orders, supplier invoices…) |
| My Inbox (F0862) | The Fiori inbox, where users approve or reject |
| Teams and Responsibilities (F2412) | Teams and people responsible per business context, to decide who receives each task |
| Flexible workflow templates (F2787) | Reusable workflow segments |
- Activate the scenario of the process you want to automate (the documentation of each area says which one).
- Open the area's Manage Workflows app and create a new workflow.
- Define the start condition: for example, orders over 10,000 euros.
- Add the steps and who approves each one.
- Order the workflows by priority: the first one whose condition is met is used.
- Activate it and test it with a real document.
In S/4HANA Cloud you can configure workflows with SAP's scenarios, but only on-premise can you develop new scenarios.
Monitoring and administration
| Transaction | What it is for |
|---|---|
| SWI1 | Find work items and workflows: status, errors, history |
| SWIA | Process work items as administrator: forward them, complete them or delete them logically |
| SWPR | Restart workflows that ended with an error |
| SWPC | Continue workflows after a system crash |
| SWEL / SWELS | Display the event trace and switch it on or off |
| SWE2 | Linkages between events and workflows (active or not) |
| SWEQADM | Administer the event queue |
| SBWP | Business Workplace: the user's classic inbox |
| SWU_OBUF | Refresh the organizational buffer after changing agents |
| SWI2_FREQ | Work item analysis by task |
| SWNADMIN | E-mail notifications of pending work items |
Do not use transaction SWWL (mass deletion of work items) in production: it really deletes them, with no way back.
Common problems
| Problem | What to check |
|---|---|
| The workflow does not start | Switch on the event trace (SWELS), repeat the action and look at it in SWEL: does the event arrive? Is the linkage active in SWE2? Did the check function discard it? |
| The work item reaches nobody | Check the possible agents of the task (PFTC) and the agent rule. After changing the organization, run SWU_OBUF |
| It reaches everybody | The task is a "general task" and the rule found no agent: then anyone can run it |
| A background step fails | Look at the error in SWI1. Background steps run with the WF-BATCH user over RFC: also check SM58 |
| After a transport, the old version is used | The new version is not active in the target system. Check the transport and activate it |
Good practices
- Raise events instead of starting the workflow directly: the program and the workflow stay decoupled.
- Think of all the events that must end the process: approved, rejected, changed, deleted…
- Include the event linkages (SWE2) in a transport request.
- Define deadlines with the factory calendar, so that holidays do not count.
- In S/4HANA, for approvals of standard documents, first check whether there is a flexible workflow scenario before building a classic one.