Beyond ABAPdesigned by@Tejoram97
Beyond ABAP / CORE ABAP / Workflow

Workflow

CORE ABAP · ABAP Development ·

Open the interactive lesson →
  1. What workflow is (the 4 rights)
  2. Architecture and runtime flow
  3. Business objects (BOR)
  4. Class-based workflow (IF_WORKFLOW)
  5. Tasks (PFTC)
  6. Workflow Builder (SWDD) and step types
  7. Containers and binding
  8. Agents and organizational management
  9. Events
  10. Work items
  11. Deadline monitoring (right time)
  12. Starting workflows and APIs
  13. Monitoring and troubleshooting
  14. Transaction codes
  15. In S/4HANA
  16. Interview questions

SAP Business Workflow: how SAP routes work to the right people, from business objects and tasks to the Workflow Builder, containers, agents, events, deadlines and troubleshooting. One running example, a leave request, is used throughout. Classic workflow (SWDD) is still used in every brownfield system and in S/4HANA on-premise, so it is taught properly; Part 15 shows the S/4HANA replacements.

Part 1 – What workflow is (the 4 rights)

A workflow is a sequence of steps (tasks), run automatically or by people, that completes one business process: approvals, notifications, document handling. Users don't need to know what to do next or when; the workflow tells them.

The classic definition is the four rights: the right work goes to the right person (a user or the system) at the right time, in the right sequence.

  • SAP Business Workflow is a cross-application engine inside the ABAP stack (component BC-BMT-WFM). It is not RPA (robots); SAP's cloud product for workflow + RPA is SAP Build Process Automation (Part 15).
  • Workflow fits processes with:
    • a fixed sequence of activities that recurs often (similar forms, similar decisions)
    • several people or groups involved, and a lot of coordination between them
    • a need to track who did what and when (audit trail, deadlines)
  • Typical examples: leave approval, purchase requisition / purchase order release, supplier invoice approval, master data change approval.
Leave request process: employee submits, workflow starts, manager approves or rejects, employee gets an automatic e-mail – with the workflow term for each step

Basic terminology

Term

Meaning

Leave request example

Workflow definition

The model: steps, rules and the path from start to end (built in SWDD)

WS90000001 "Approve leave"

Workflow instance

One actual run of a workflow definition

Leave request of employee 4711

Task

A reusable activity, done by a person or the system (PFTC)

TS90000010 "Approve request"

Step

A node in the workflow definition; an activity step calls a task

Step "Manager approves"

Work item

The runtime instance of a step / task – what appears in the inbox

The approval item for the manager

Agent

A person who processes work items

The manager

Container

The data store of a workflow, task, method, rule or event

LeaveRequest, Approver

Binding

Copying data from one container to another

Event object → workflow element

Event

A signal that something happened to an object; can start or end work

LeaveRequest.CREATED

The execution process

  • 1. An event is raised (leave request created, invoice received).
  • 2. The linked workflow starts and its container is filled from the event.
  • 3. Each step creates a work item; agent determination decides who gets it.
  • 4. The agent processes it in the inbox (approve, reject, other).
  • 5. The workflow completes; it may raise another event.
  • 6. Everything is logged: monitor in SWI1 / the workflow log.

Part 2 – Architecture and runtime flow

Workflow sits between the organization (who), the process (which steps, when) and the business objects (what work, as executable methods). ABAP programs raise events that start the process.

Workflow architecture: organization (right person), process (right sequence and time), business objects or classes (right work) and the ABAP application that raises events, with the components and tools of each layer

Layer

Question it answers

Contains

Tools

Organization (HR OM)

Who executes the steps? (right person)

Org units, positions, jobs, users, rules

PPOME, PFAC

Process (workflow)

Which steps, in which order, by when? (right sequence & time)

Workflow definition, steps, deadlines

SWDD

Business objects / classes

What is done? (right work)

Attributes, methods, events of an object

SWO1, SE24

Application / ABAP

When does it start?

Raises events (or starts the workflow)

SWE2, WAPIs

The same pieces at runtime – what happens from the moment an event is raised until the agent finishes:

Runtime flow: event raised, event manager reads the type linkage, workflow instance starts, step creates a work item, agent executes it, step completes

Part 3 – Business objects (BOR)

A business object (BO) represents a real-world entity – vendor, customer, material, purchase order, sales order – as a collection of attributes, methods and events. It wraps the DDIC tables, the application code and the business documents behind one interface. The workflow only talks to the object, never to its tables. Business object types live in the Business Object Repository (BOR) and are maintained in SWO1.

  • Object type = the definition (like a class), e.g. BUS2012 purchase order, BUS2105 purchase requisition, BUS2081 supplier invoice. Object = one instance with a key (like an object of a class).
  • Outside view: users of a BO (workflow designers) call its methods without knowing the tables. Inside view: the developer who implements or extends it sees the code.
Business object type and object; the five components key fields, attributes, methods, events and interfaces, each with its IF_WORKFLOW class equivalent

Properties of a BO type

Property

Meaning

Object type (ID)

Internal identification, e.g. ZXXXATTDNC (max 10 characters)

Object name

External name used by programs and external systems, e.g. Employee_Attendance

Supertype

Parent type; all its components are inherited

Name / Description

Descriptive name and short text

Program

The ABAP program that holds the BO's implementation

Application

Application component the type belongs to

SWO1 step by step: Create Object Type dialog for ZXXXATTDNC, component tree with inherited key fields and events, implement, release status, generate and test

The five components

Component

What it is

Rules

Key fields

One or more fields that identify one instance; refer to the application table key

Character-based; concatenated max 70 characters; set at creation, read-only from outside

Attributes

Properties of the object, read-only from outside

Single- or multi-line; instance-dependent or static. DB field: read automatically from the table field linked to the key. Virtual: computed in the BO program (GET_PROPERTY … END_PROPERTY) – from another table, a calculation or an object reference

Methods

Functions of the object (Display, Change, Approve, CreateDelivery…)

Instance-dependent or instance-independent (static); parameters (import/export, mandatory/optional, single/multi-line) and exceptions

Events

Signal a status change (created, changed, released)

Can have parameters; the listeners are outside the BO (a workflow)

Interfaces

Shared components inherited by object types

No key, no instances; a type can implement several (replaces multiple inheritance); interface methods can have an implementation and be redefined in the object type; IFSAP (ExistenceCheck, Display) is inherited by every type

Methods are classified in two independent ways:

  • Dialog (runs in the agent's session, needs user input) vs background (runs as the workflow system user, no screen).
  • Synchronous (returns result, export parameters and exceptions; the step finishes when the method returns) vs asynchronous (returns nothing to the step; the work item completes only when a terminating event arrives, e.g. changed after the user edited the document).
  • Implementation types: function module, transaction, dialog module, report, BAPI, or other – code between BEGIN_METHOD and END_METHOD in the BO program.

Release status

Set the status of each component first, then of the object type. Status has nothing to do with transport – BOR objects are transported with normal transport requests at any status.

Status

Meaning

Modeled

Default after creation: only the definition/signature exists. Cannot be executed in a workflow

Implemented

Code exists; usable in workflows and for testing (the builder warns)

Released

Stable and supported for productive use

Obsolete

Old functionality, possibly replaced; don't use it

Delegation – extending an SAP object type

You may not change SAP's object types. Instead create a subtype, add your attributes, methods and events there, and delegate the supertype to it. Every use of the SAP type (tasks, events, workflows) then uses your subtype automatically, so SAP-delivered tasks see your extensions without being redefined.

  • 1. SWO1: create a subtype (Supertype BUS2012, object type ZBUS2012), add components, implement, set status.
  • 2. SWO6 (or SWO1 › Settings › Delegate): delegate BUS2012 → ZBUS2012.
  • 3. Keep using BUS2012 in tasks and linkages; at runtime the delegated subtype's code runs.

BOR programming: macros

BOR programs use macros from include <CNTN01> to work with objects and containers. A macro is compile-time text substitution, not an object-oriented feature:

DEFINE add_log.  " &1..&9 are replaced by the call's operands
APPEND VALUE #( step = &1 text = &2 ) TO &3.
END-OF-DEFINITION.

add_log 10 'Request checked' lt_log.  " call: macro name + operands
  • Macros can't be debugged step by step and hide logic; SAP discourages new ones – write methods instead (general modularization: see page 04 Modularization).
  • The SWC_* container macros are still needed inside legacy BOR methods and rule function modules:

Macro

Purpose

SWC_GET_ELEMENT / SWC_SET_ELEMENT

Read / write a single-value container element

SWC_GET_TABLE / SWC_SET_TABLE

Read / write a multi-line container element

SWC_CREATE_OBJECT

Create an object reference (wraps FM SWO_CREATE)

SWC_GET_PROPERTY

Read an attribute of an object reference

BEGIN_METHOD / END_METHOD

Frame of a method implementation in the BO program

BEGIN_METHOD zapprove CHANGING container.
DATA: lv_comment TYPE string,
lv_result  TYPE char1.
swc_get_element container 'Comment' lv_comment.  " import parameter
" ... approve the request identified by object-key ...
lv_result = 'A'.
swc_set_element container 'Result' lv_result.    " export parameter
END_METHOD.
  • Legacy BOR containers are internal tables of structure SWCONT (ELEMENT = name, VALUE = value; a multi-line element is several rows with the same name). The modern runtime uses class-based containers (IF_SWF_IFS_PARAMETER_CONTAINER); WAPIs use tables of SWR_CONT.

In S/4HANA / clean core: SAP still ships BOR types (BUS2012, BUS2105…) and they keep working, but BOR is in maintenance. Build new workflow objects as ABAP classes (Part 4).

Part 4 – Class-based workflow (IF_WORKFLOW)

Any ABAP class (SE24) can be used in workflow if it implements interface IF_WORKFLOW. It bundles two interfaces: BI_PERSISTENT (how the engine stores and rebuilds the instance) and BI_OBJECT (display behaviour). This is the recommended way for new development. Old documents call the engine the "SAP WebFlow Engine" – the same thing as SAP Business Workflow.

Method

Purpose

BI_PERSISTENT~FIND_BY_LPOR (static)

Rebuild an instance from its key (LPOR) when the engine needs it

BI_PERSISTENT~LPOR

Return the instance key as structure SIBFLPOR

BI_PERSISTENT~REFRESH

Reload buffered data

BI_OBJECT~DEFAULT_ATTRIBUTE_VALUE

Text shown for the object (e.g. in the work item)

BI_OBJECT~EXECUTE_DEFAULT_METHOD

Default action when a user clicks the object (usually display)

BI_OBJECT~RELEASE

Free the instance

  • LPOR = SIBFLPOR: CATID = 'CL', TYPEID = class name, INSTID = key. INSTID is only 32 characters (BOR keys allow 70) – a common pitfall when keys are long.
  • Public attributes act as workflow attributes, public methods as task methods (dialog or background is set in the task), public events as workflow events. Functional methods can be used in expressions; static utility classes suit background calculations.
CLASS zcl_leave_request DEFINITION PUBLIC CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_workflow.
DATA request_id TYPE char10 READ-ONLY.
EVENTS created EXPORTING VALUE(approver) TYPE syuname.
METHODS constructor IMPORTING iv_id TYPE char10.
METHODS approve.
PRIVATE SECTION.
DATA ms_lpor TYPE sibflpor.
ENDCLASS.

CLASS zcl_leave_request IMPLEMENTATION.
METHOD constructor.
request_id = iv_id.
ms_lpor = VALUE #( catid = 'CL' typeid = 'ZCL_LEAVE_REQUEST' instid = iv_id ).
ENDMETHOD.
METHOD bi_persistent~find_by_lpor.
result = NEW zcl_leave_request( CONV #( lpor-instid ) ).
ENDMETHOD.
METHOD bi_persistent~lpor.
result = ms_lpor.
ENDMETHOD.
METHOD bi_persistent~refresh.
ENDMETHOD.
METHOD bi_object~default_attribute_value.
result = REF #( request_id ).
ENDMETHOD.
METHOD bi_object~execute_default_method.
ENDMETHOD.
METHOD bi_object~release.
ENDMETHOD.
METHOD approve.
" business logic: update the request status
ENDMETHOD.
ENDCLASS.

BOR object type

ABAP class with IF_WORKFLOW

Tool

SWO1 (Business Object Builder)

SE24 / ADT

Code style

Macros in a BO program

Normal ABAP OO, modern syntax, unit tests

Key length

Up to 70 characters

INSTID up to 32 characters

Extending SAP

Subtype + delegation (SWO6)

Inheritance or your own class

Events raised by

SAP_WAPI_CREATE_EVENT / SWE_EVENT_CREATE

CL_SWF_EVT_EVENT

Status

Legacy, still used by SAP standard

Recommended for new development

Part 5 – Tasks (PFTC)

A task is an activity done by a person (dialog) or the system (background): execute a report, approve leave, post an invoice. It points to one method of a BO type or class. Tasks are created in PFTC; at runtime each execution is a work item. A task group (TG) bundles logically related tasks, even across application components.

Type

Prefix

Kind

Client

Validity

Use

Standard task

TS

Single-step

Cross-client

None

Always use

Customer task

T

Single-step

Client-specific

Yes

Obsolete – compatibility only

Workflow template

WS

Multi-step

Cross-client

None

Always use

Workflow task

WF

Multi-step

Client-specific

Yes

Obsolete – compatibility only

Task group

TG

Grouping

–

–

Group tasks for authorization / overview

  • Plan versions: a standard task (TS) is valid in all plan versions; a customer task (T) is plan-version-specific (and client-dependent).
  • The system numbers tasks with an 8-digit ID after the prefix (TS90000010). The first three digits are the prefix number, maintained in SWU3 › Maintain prefix numbers (transaction OOW4); each system/client needs its own prefix so IDs never clash.

What you set in a task

  • Object category (BOR object type or ABAP class), object type, method; background processing yes/no.
  • Synchronous / asynchronous comes from the method; an asynchronous method needs a terminating event.
  • Work item text with variables, e.g. Approve leave &_WI_OBJECT_ID.REQUEST_ID&, plus a long description.
  • Task container and task → method binding.
  • Agent assignment (possible agents): org objects, or classify it as a General task (Additional data › Agent assignment › Attributes) so every user is a possible agent.
  • Flags: Confirm end of processing (the agent must confirm completion explicitly, status COMMITTED until then); Advance with dialog (in the workflow step: the next dialog step opens immediately for the same user).

An activity step that references a task becomes one of three work item kinds: a dialog work item (task with dialog; only these reach an inbox), a background work item (no dialog), or a workflow work item (the activity is a sub-workflow).

Part 6 – Workflow Builder (SWDD) and step types

The Workflow Builder (SWDD) creates, displays and changes multi-step workflows (WS). Everything, including the workflow container, is maintained there, in a graphical or a tree view.

Workflow Builder screen areas: Information, Navigation, Objects (left), Workflow model (centre), Overview and Step types (right), Messages (bottom)

Area

Shows

Information / Navigation

Workflow ID, version, status; list of steps to jump to

Objects

Workflow container, tasks, documents, outcomes – drag and drop into steps

Workflow

The graphical model you edit

Overview / Step Types

Miniature of the whole model; the step types you can insert

Messages

Results of the consistency check and search

A step is the basic building block: it either executes a task or controls the flow. A step always sits inside a block together with its outcomes; at runtime a step becomes a work item.

Workflow Builder step types with their original icons, and the six status icons

Step type

Runtime function

ABAP analogy / note

Activity

Runs a task (TS) or a sub-workflow (WS)

A method call

User decision

The agent picks one of several outcomes (with optional decision note)

Dialog with N buttons

Condition

Two branches (true / false) from the container or object attributes

IF … ELSE … ENDIF

Multiple condition

Several branches, chosen by the value of one container element; an "other values" branch catches the rest

CASE … WHEN … WHEN OTHERS

Container operation

Assigns a value or calculates: &COUNTER& = &COUNTER& + 1, append to a multi-line element. It never branches

a = b + 1 / APPEND

Loop (UNTIL)

Body runs at least once, stops when the condition becomes true

DO … IF cond. EXIT.

Loop (WHILE)

Condition checked first; body runs while it is true (maybe never)

WHILE cond. … ENDWHILE

Fork

Parallel branches; ends after n of m branches (e.g. 2 of 3 approvers) or an end condition; open branches are then logically deleted

Parallel processing

Process control

Cancel a work item, cancel a workflow, set a work item obsolete, complete a workflow, raise an exception

LEAVE / RAISE

Event creator

Raises an event (workflow → event container binding)

RAISE EVENT

Wait for event

Work item completes only when the expected event (or XML document) arrives

Waits via an instance linkage

Send mail

Sends the entered text to agents / addresses; status log in SOST, SAPconnect configuration in SCOT

–

Form

Shows, edits or approves a structure-typed container element as a form

Simple screen

Document from template

Creates a document from a template; the user can change it

–

Web activity

Posts container elements to a URL (raw or as XML); can wait for a reply

HTTP call

Ad hoc anchor

At runtime an authorized user picks a saved workflow whose steps replace the anchor

–

Undefined step

Placeholder with no runtime function; always has an outcome

Empty statement

A local workflow (block) groups steps that can be triggered as a unit inside the same workflow; a sub-workflow is a separate WS called by an activity step.

Inserting a step

To insert …

Select …

After a step

The step's outcome in the right branch, then create the step

Before a step

The step itself

A new branch in a fork

The fork symbol ("new branch" icon) in front of the fork

Into an empty model

Right-click the undefined step and choose a step type

Building a workflow end to end

  • 1. SWU3 – automatic workflow customizing: RFC destination WORKFLOW_LOCAL_<client>, workflow system user, prefix numbers, background jobs. All lights green.
  • 2. Object – a BOR subtype (SWO1 + SWO6) or a class with IF_WORKFLOW (SE24), with methods and events; status Implemented/Released or class activated.
  • 3. PFTC – standard task TS: object category, type, method, terminating events (if asynchronous), work item text, task → method binding, possible agents or general task.
  • 4. SWDD – workflow template WS. Workflow container: an import element typed with the BO/class. Basic data › Start events: object type + event, binding _EVT_OBJECT → element, activate the linkage.
  • 5. Steps – activity (task TS) with workflow → task binding, agents, deadlines, outcomes; add user decisions, conditions, loops as needed.
  • 6. Check, activate, save to a transport request.
  • 7. Test – SWUS (with import data) or SWUE (fire the event); trace in SWEL; log in SWI1; inbox in SBWP or My Inbox.

Older solutions start a single-step task directly from a triggering event (PFTC › Triggering events tab). That still works but is legacy practice – use a WS with start events.

Part 7 – Containers and binding

A container holds all variables (container elements) of one workflow instance, task, method, rule or event – the persistent memory of the process. Values come from binding or from direct assignment (container operation).

Container

Container element

Definition

The structure of all variables of one instance

One variable inside it

Scope

All data of one workflow / work item / event

One value (or one table if multi-line)

Type

Not a type itself

Typed: DDIC type, BOR type or class

Example

Leave request workflow container

Employee_Name, Leave_Start_Date, Approval_Status

Purpose

Keeps the workflow's data for its whole life

Passes individual values between steps

  • Five container types: workflow, task, method, rule, event.
  • Element properties: Import, Export, Mandatory, Multiline.
  • Expressions reference elements and their attributes as &ELEMENT.ATTRIBUTE&, e.g. &LeaveRequest.Requester&.
Containers and binding: event → workflow one way; workflow ⇄ task and task ⇄ method both ways; workflow → rule and workflow → event one way

Binding

Direction

Maintained in

Event → workflow

One way

SWDD › Basic data › Start events

Workflow ⇄ task

Both ways

SWDD › step › Binding

Task ⇄ method

Both ways

PFTC › Binding

Workflow → rule

One way

Step agent assignment with a rule

Workflow → event

One way

Event creator step

System elements

Element

Content

_WF_INITIATOR

User who started the workflow (US<user>)

_EVT_OBJECT / _EVT_CREATOR

Object that raised the event / user who raised it (event container)

_WI_OBJECT_ID

Leading object of the work item (task container)

_WORKITEM

The work item itself (task container)

_WI_RESULT

Result of the step (e.g. the user decision)

_ATTACH_OBJECTS

Attachments added by agents

Programmatic access at runtime: SAP_WAPI_READ_CONTAINER and SAP_WAPI_WRITE_CONTAINER (Part 12).

Part 8 – Agents and organizational management

HR Organizational Management (OM) gives the right person: it maps departments, positions and people to workflow agents. Maintain the structure in PPOME (display PPOSE); PPOCW / PPOMW / PPOSW are the older transactions. PFOM / PFOS assign or display SAP org objects; PFSO shows a user's org environment.

OM object

Type

Example

Organizational unit

O

Finance, HR, Sales

Position

S

Manager Sales North (one person holds it)

Job

C

General description, e.g. "Sales Manager"; describes many positions

Person / user

P / US

The employee / the SAP user holding the position

Task

TS / T

Tasks can be assigned to jobs or positions (possible agents)

  • In workflow, "role" is the old name of a rule (object type AC, PFAC) – not a PFCG authorization role and not an OM object.

Agent types

Agent

Defined in

Meaning

Possible agents

Task (PFTC)

Who may execute the task at all (or everyone: general task)

Responsible agents

Step (SWDD) or task default

Who should get this particular work item

Excluded agents

Step

Who must not get it (e.g. the requester himself)

Recipients

Calculated

(possible ∩ responsible) − excluded

Actual agent

Runtime

The user who executes the work item

Agent determination: recipients are possible agents intersected with responsible agents, minus excluded agents

Ways to determine responsible agents

  • Static: a fixed org object (org unit, position, job, user) – simple, but breaks when people move.
  • Expression: a container element, e.g. &_WF_INITIATOR& or an Approver element filled earlier.
  • Organizational: from OM, e.g. the requester's manager. Standard rule 00000168 (chief position) is the classic "manager of" rule.
  • Rule (PFAC): business logic at runtime, e.g. a PO above a threshold goes to the department head. Rule types: responsibilities, function to be executed (FM), organizational data, evaluation path. SWDD and PFTC only reference a rule, with a workflow → rule binding.

A rule function module has a fixed interface. Example – find the approver of a cost center from a custom table:

FUNCTION z_wf_rule_cost_center_approver.
*"  TABLES
*"     ACTOR_TAB    STRUCTURE SWHACTOR
*"     AC_CONTAINER STRUCTURE SWCONT
*"  EXCEPTIONS
*"     NOBODY_FOUND
" INCLUDE <cntn01> must be in the function group's TOP include
DATA: lv_kostl TYPE kostl,
ls_actor TYPE swhactor.

swc_get_element ac_container 'COSTCENTER' lv_kostl.  " filled by the rule binding

SELECT SINGLE approver FROM zwf_cc_approver
WHERE kostl = @lv_kostl
INTO @DATA(lv_approver).

IF sy-subrc = 0.
ls_actor-otype = 'US'.  " could also be 'S' (position) or 'O' (org unit)
ls_actor-objid = lv_approver.
APPEND ls_actor TO actor_tab.
ENDIF.

IF actor_tab[] IS INITIAL.
RAISE nobody_found.
ENDIF.
ENDFUNCTION.
  • Test a rule with Simulate in PFAC. If it finds nobody, the item goes to all possible agents – unless the step flag Terminate if rule resolution has no result is set, then the workflow goes into error.
  • Substitution (SBWP / My Inbox): active substitutes see the items automatically, passive ones must adopt the substitution first. Administrators can forward work items in SWIA.
  • OM changes not visible? Refresh the org buffer with SWU_OBUF.

Part 9 – Events

An event announces that the status of an object changed – report generated, leave submitted, invoice posted. It is published to the system; any number of receivers can react.

Use

Effect

Linkage

Triggering (start) event

Starts a workflow

Type linkage: SWE2 / SWETYPV (every object of the type)

Terminating event

Completes a waiting work item (asynchronous method, wait step)

Instance linkage: SWE3 / SWEINST (only this object instance), created by the engine

Type linkage (SWE2)

One entry = object category + object type + event → receiver. Normally created automatically when you activate a start event in SWDD; SWETYPV is a view on the same table.

  • Receiver type / receiver FM: usually the workflow WS with FM SWW_WI_CREATE_VIA_EVENT_IBF.
  • Start condition (SWB_COND, also in SWDD Start events) or a check FM: start only if, e.g., amount > 1000.
  • Linkage activated flag; the event queue (SWEQADM, SWEQBROWSER) can buffer events to spread load.
  • Events are delivered only after COMMIT WORK, normally by tRFC (asynchronously, destination WORKFLOW_LOCAL_<client>, as the workflow system user). The relevant sync/async distinction is between methods (Part 3), not events.

How events are raised

  • By the application, without code: change documents (SWEC), status management (BSVW), output / message control, Business Transaction Events, HR infotype events.
  • By the workflow: an Event creator step.
  • Manually for tests: SWUE – enter object type, key and event, execute.
  • From ABAP – BOR object, recommended WAPI:
DATA: lv_key  TYPE swr_struct-object_key,
lt_cont TYPE STANDARD TABLE OF swr_cont,
lv_rc   TYPE sy-subrc.

lv_key = lv_request_id.
lt_cont = VALUE #( ( element = 'APPROVER' value = lv_approver ) ).

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
EXPORTING
object_type     = 'ZLEAVEREQ'
object_key      = lv_key
event           = 'CREATED'
commit_work     = abap_true
IMPORTING
return_code     = lv_rc
TABLES
input_container = lt_cont.

" Legacy: CALL FUNCTION 'SWE_EVENT_CREATE' (objtype, objkey, event, TABLES event_container)
" followed by COMMIT WORK. In an update task: SWE_EVENT_CREATE_IN_UPD_TASK.
  • From ABAP – class-based object:
DATA(lo_event) = cl_swf_evt_event=>get_instance(
im_objcateg = cl_swf_evt_event=>mc_objcateg_cl
im_objtype  = 'ZCL_LEAVE_REQUEST'
im_event    = 'CREATED'
im_objkey   = CONV sibfinstid( lv_request_id ) ).
DATA(lo_cont) = lo_event->get_event_container( ).
lo_cont->set( name = 'APPROVER' value = lv_approver ).  " event parameter
lo_event->raise( ).
COMMIT WORK.  " delivery happens only now

Event trace (SWELS / SWEL)

Switch the trace on with SWELS (old: SWE4), reproduce, then read SWEL. Switch it off again in production; old entries are deleted with report RSWELOGD. Typical SWEL results:

SWEL text

Meaning / next check

Receiver started correctly

Workflow started – continue in SWI1

No receiver entered

No active type linkage for this object type + event (SWE2, start events in SWDD)

Check FM ended with exception

Start condition / check FM said "don't start" – usually intended

Receiver could not be started / feedback error

Binding or workflow problem – look in SM58 and SWI1

Part 10 – Work items

A work item is the runtime instance of one step or task. Dialog work items reach the agent's inbox: SBWP (Business Workplace, SAP GUI), the Portal UWL, SAP Fiori My Inbox (F0862) or SAP Task Center.

Type

Key

Description

In inbox?

Dialog work item

W

A step or single-step task that needs user dialog

Yes

Missed deadline

D

Notification that a deadline was missed

Yes

Work queue

A

Objects processed once and together in a limited time frame

Yes

Workflow

F

Runtime presentation of a workflow or sub-workflow

No

Block

X

Runtime presentation of a block

No

Background

B

A step without dialog, run by the system

No

Wait step

E

A wait-for-event step

No

Web

R

A web activity

No

Container anchor

C

Special EDI development; delete or archive regularly

No

Statuses

Status of a workflow / sub-workflow (icons in kw04 above):

Status

Meaning

Waiting

Scheduled; the requested start has not been reached yet

Ready

Temporary interim status

In process

Execution has begun

Completed

The end has been reached

Logically deleted

No longer needed: set by an administrator (only before Completed), by a process control step, or by a fork that has enough branches. Applied recursively to open dialog and workflow work items. Database changes or events already made are not rolled back – only logged

Error

An error in workflow control – fix and restart (SWPR)

Technical status of a dialog work item (field WI_STAT):

Status

Meaning

WAITING

Requested start in the future

READY

In the inbox of all recipients, nobody has taken it yet (a user decision stays here until processed)

SELECTED

Reserved by one recipient – gone from the other inboxes

STARTED

In process (the workflow work item is STARTED while its steps run)

COMMITTED

Executed, waiting for "confirm end of processing"

COMPLETED / CANCELLED

Finished / logically deleted

ERROR

Error during execution

CHECKED

In preparation (created, not yet released)

Part 11 – Deadline monitoring (right time)

Deadlines make sure work items are processed in time. Each step has four deadline tabs; each deadline is a reference date/time (work item creation, workflow start, or a container element) plus an offset.

Deadline

Meaning

Typical use

Requested start

Earliest time the work item is delivered

Delay delivery (e.g. a few minutes, or until a date)

Latest start

Latest time processing may begin

Alert if nobody picked it up

Requested end

When it should be completed

Reminder, e.g. after 5 of 7 days

Latest end

Latest time to finish without breaching

Escalate to the supervisor

  • Action when missed: display text – a missed-deadline work item (type D) is sent to the recipients you name (e.g. the supervisor); modelled – an extra outcome branch where you model the escalation (forward, process control "set obsolete", send mail).
  • Needs background job SWWDHEX (report RSWWDHEX), scheduled from SWU3. Without it no deadline fires.
  • Report SWI2_DEAD lists work items with monitored deadlines; deadlines can be changed at runtime in SWIA or with FM SWW_WI_DEADLINES_CHANGE.

Part 12 – Starting workflows and APIs

Way

How

Notes

By event

Start event / type linkage (Part 9)

Normal productive way

Manually (user)

SWUI – start workflows the user is a possible agent of

Workflow needs possible agents

Manually (test)

SWUS – enter import container values and start

Developer test; SWUE fires the event instead

From ABAP

SAP_WAPI_START_WORKFLOW

When there is no suitable event

Only a possible agent of the workflow (or of a general task) can start it manually; a dialog task without possible agents can neither be started nor executed. SBWP is the inbox for processing work items, not the start transaction.

DATA: lt_cont TYPE STANDARD TABLE OF swr_cont,
lv_wi   TYPE sww_wiid,
lv_rc   TYPE sy-subrc.

lt_cont = VALUE #( ( element = 'REQUESTID' value = lv_request_id ) ).

CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
EXPORTING
task            = 'WS90000001'
do_commit       = abap_true
IMPORTING
return_code     = lv_rc
workitem_id     = lv_wi
TABLES
input_container = lt_cont.

Workflow APIs (WAPIs)

Function module

Purpose

SAP_WAPI_START_WORKFLOW

Start a workflow with a container

SAP_WAPI_CREATE_EVENT

Raise a BOR event

SAP_WAPI_READ_CONTAINER / SAP_WAPI_WRITE_CONTAINER

Read / change a work item's container

SAP_WAPI_WORKITEM_COMPLETE

Complete a work item

SAP_WAPI_DECISION_COMPLETE

Complete a user decision with a chosen outcome

SAP_WAPI_GET_WORKITEM_DETAIL

Read work item details

SAP_WAPI_WORKITEMS_TO_OBJECT

All work items for an object

SAP_WAPI_ADM_WORKFLOW_CANCEL

Cancel a workflow (administrator)

Older internal FMs – prefer the WAPIs: SWW_WI_CONTAINER_READ (read a container), SWW_WI_DEADLINES_CHANGE (change deadlines), SWW_WI_ENABLE / SWW_WI_DISABLE (unlock / lock a work item for execution).

Part 13 – Monitoring and troubleshooting

Runtime customizing (SWU3)

  • Creates logical RFC destination WORKFLOW_LOCAL_<client> (e.g. WORKFLOW_LOCAL_800): background steps and event delivery run through it as the workflow system user SAP_WFRT (older systems: WF-BATCH).
  • Schedules the jobs: SWWDHEX deadlines, SWWERRE error monitoring (restarts failed tRFC calls), SWWCOND work item start/end conditions, SWWCLEAR clean-up of job logs, SWEQSRV event queue.
  • Maintains prefix numbers and the default for general tasks. All lights must be green.

Checklist

Symptom

Check, in this order

Workflow didn't start

SWELS on → repeat → SWEL. No receiver? → linkage active in SWE2 / start events. Check FM exception? → start condition. Receiver error? → SM58 (tRFC), binding, SWU3 green, event raised before COMMIT WORK?

Workflow in error

SWI1 or SWI2_DIAG → open the log (technical view, container, messages) → fix the cause → SWPR restart after error, or complete manually in SWIA. After a system crash: SWPC

No recipient / wrong recipient

SWI1 → work item → agents. Possible agents in PFTC (general task?), responsible agents in the step, rule simulation in PFAC, OM assignment, SWU_OBUF refresh

Background step fails

ST22 dump, SM37 workflow jobs, SM58, user SAP_WFRT authorizations

Deadline doesn't fire

Job SWWDHEX scheduled (SWU3)? SWI2_DEAD

Mail not received

SOST send status, SCOT configuration

Need deeper trace

SWU8 workflow trace on, SWU9 display, SWU10 delete; SWUD diagnosis wizard

  • Housekeeping: old work items are archived with archiving object WORKITEM; report RSWWWIDE deletes work items (test systems only). SWU_CONT_PERSISTENCE sets container storage (XML vs table).

Part 14 – Transaction codes

Group

T-code

Purpose

Design

SWDD

Workflow Builder (WS)

PFTC

Create / maintain tasks (TS, WS, TG)

SWO1 / SWO6

Business Object Builder / delegation of object types

SE24

Class Builder (IF_WORKFLOW classes)

PFAC

Create / maintain rules

SWDD_SCENARIO

Flexible workflow scenario definition (S/4HANA)

SWDM

Business Workflow Explorer (find workflows and tasks)

Runtime / inbox

SBWP

Business Workplace (inbox, substitutes); Fiori: My Inbox

SWUI

Start workflows (end user)

SWUS

Test: start a workflow or task with import data

Events

SWE2 / SWETYPV

Type linkages (event → receiver)

SWE3 / SWEINST

Instance linkages

SWUE

Generate (fire) an event

SWELS / SWEL

Event trace on/off / display event trace

SWEC

Link change documents to events

SWB_COND

Start conditions for linkages

SWEQADM / SWEQBROWSER

Event queue administration / browser

SWU0

Event simulation (which receivers would start?)

Monitoring / admin

SWI1

Selection report for work items (+ workflow log)

SWI2_FREQ / SWI2_DURA

Work items per task / by processing duration

SWI2_DIAG

Workflows with errors

SWI2_DEAD

Work items with monitored deadlines

SWI5 / SWI6

Workload analysis / workflows for an object

SWIA

Process work items as administrator (complete, forward, logically delete)

SWPR / SWPC

Restart after error / continue after system crash

SWU8 / SWU9 / SWU10

Workflow trace on / display / delete

SWUD

Diagnosis tools

SOST / SM58 / SM37

Mail send status / tRFC errors / jobs

SWU4–SWU7

Consistency checks (standard tasks, customer tasks, workflow tasks, templates)

Customizing

SWU3

Automatic workflow customizing (RFC destination, user, jobs, prefixes)

OOW4

Prefix numbers for tasks

SWNCONFIG / SWNADMIN

Extended notifications (e-mail about new work items)

SCOT

SAPconnect (mail configuration)

PPOME / PPOSE

Maintain / display org structure (older: PPOCW, PPOMW, PPOSW)

PFOM / PFOS / PFSO

Assign / display SAP org objects / org environment of a user

SWU_OBUF

Refresh the runtime (org) buffer

  • Rarely needed, from the old list: SWDA (alphanumeric builder, very old), SWDS (builder selection), SWDC_DEFINITION / SWDC_RUNTIME (builder admin data), SWDD_CONFIG (workflow configuration), SWI11 / SWI13 (tasks in workflows / task profile), SWL1 / SWLV (inbox columns / work item views), SWFVISU (UWL visualisation), SWU2 (RFC monitor), SWU_EWCD / SWU_EWLIS / SWU_BTE / SWUY (event creation wizards), SWXML (XML documents), SWED (change documents to object types), SWR_WEBSERVER, WF_HANDCUST, WF_EXTSRV, WFWS (web service handling).

Part 15 – In S/4HANA

In S/4HANA / clean core: configure a Flexible Workflow if SAP delivers a scenario; otherwise build a class-based SWDD workflow (on-premise / private cloud) or a side-by-side process in SAP Build Process Automation.

Part 16 – Interview questions

Q1. What is SAP Business Workflow and when do you use it?

An engine in the ABAP stack that routes the right work to the right person at the right time in the right sequence. Use it for recurring processes with several people, approvals and a need for tracking.

Q2. Task vs step vs work item?

A task (PFTC) is a reusable activity pointing to one method. A step is a node in a workflow definition; an activity step calls a task. A work item is the runtime instance of a step/task – what lands in the inbox.

Q3. TS vs WS, and standard vs customer task?

TS = single-step standard task, WS = multi-step workflow template; both cross-client without validity. Customer tasks (T) and workflow tasks (WF) are client-specific with validity periods and obsolete.

Q4. BOR object vs class-based workflow?

BOR: SWO1, macros, key up to 70 characters, delegation via SWO6, legacy. Class: SE24 with IF_WORKFLOW (BI_PERSISTENT + BI_OBJECT), normal ABAP OO, key INSTID up to 32 characters, recommended.

Q5. Synchronous vs asynchronous method?

Synchronous returns results and the step ends when the method returns. Asynchronous returns nothing to the step; the work item completes only when a terminating event arrives.

Q6. What is binding, and how is it different from a container operation?

Binding copies data between containers (event → workflow, workflow ⇄ task ⇄ method, workflow → rule). A container operation is a step that assigns or calculates values inside the workflow container.

Q7. Condition vs multiple condition? Loop UNTIL vs WHILE?

Condition = two branches (IF/ELSE). Multiple condition = N branches by the value of one element (CASE). UNTIL runs at least once and stops when true; WHILE checks first and runs while true.

Q8. Possible, responsible, excluded and actual agents?

Possible = may execute (task). Responsible = should get it (step). Excluded = must not get it. Recipients = (possible ∩ responsible) − excluded; the one who executes is the actual agent. No responsible agent → all possible agents; a general task makes everyone possible.

Q9. How do you trigger a workflow from ABAP?

Raise an event: SAP_WAPI_CREATE_EVENT (BOR) or CL_SWF_EVT_EVENT (class), then COMMIT WORK; the type linkage starts the workflow. Or start it directly with SAP_WAPI_START_WORKFLOW.

Q10. Type linkage vs instance linkage?

Type linkage (SWE2): every object of a type + event → receiver, used for start events. Instance linkage (SWE3/SWEINST): one specific object instance, created by the engine for terminating events and wait steps.

Q11. A workflow did not start – how do you analyse it?

SWELS on, repeat, SWEL: no receiver → activate the linkage; check FM exception → start condition; receiver error → SM58, binding, SWU3. If it started but failed: SWI1 / SWI2_DIAG, log, fix, SWPR.

Q12. What replaces classic workflow in S/4HANA?

Flexible Workflow (key users configure SAP scenarios in Manage Workflows; extend via BAdIs), My Inbox, and SAP Build Process Automation on BTP for side-by-side processes. Classic SWDD workflow remains supported on-premise.

🏠 Start Here · ◀ 11 · Forms · 13 · BRF+ ▶ · Sections: CORE ABAP | OOPS ABAP | ABAP on HANA | Clean Core | RAP | ABAP Points | SAP Fiori | SAPUI5 | Mobile Development (MDK) | BTP Foundations | BTP Development | CAP | SAP Build | ABAP on BTP | Integration Suite | SAP Business AI | SAP BASIS | Security | SAP SDLC

Functional: FICO ABAP | TRM ABAP | VIM | SAP BIS | SD ABAP | MM ABAP | PP ABAP | QM ABAP | PM ABAP | PS ABAP | EWM | TM ABAP | EHS ABAP | HR ABAP | BW | SAP MDG | SAP Analytics Cloud | SAP Ariba | SAP CX | SAP IBP