Workflow
ABAP Developmentintermediate

Workflow Part 3: Agent Determination and Rule-Based Assignment

Key takeaway

Understand how SAP Workflow decides who receives a work item: possible agents (task), responsible agents (step: org objects, expressions, rules), excluded agents, general tasks, rules in PFAC (responsibility and function-module rules), organizational management in PPOME, rule resolution errors, and substitutes.

Explanation

📌 KEY POINTS
✅ The actual recipients = responsible agents (from the step) ∩ possible agents (from the task), minus excluded agents.

✅ Responsible agents come from org objects (org unit, position, job), expressions (container elements like the requester's manager) or rules (PFAC: responsibility rules or function-module rules).

✅ A task marked "general task" allows all users as possible agents — convenient, but less controlled.

⚠️ If no agent is found (and the rule doesn't terminate on error), the work item goes to all possible agents — for a general task that can mean everyone in the company.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Part 2 built steps. Now each dialog step needs the right people.

━━━━━━━━━━━━━━━━━━━━
▶ 1. THREE AGENT SETS

  • Possible agents: assigned to the task (PFTC → agent assignment) — who may ever execute it; or "general task".
  • Responsible agents: defined per step — who should execute it in this case.
  • Excluded agents: e.g. the requester must not approve their own request.
  • Recipients = responsible ∩ possible − excluded.

━━━━━━━━━━━━━━━━━━━━
▶ 2. WAYS TO DEFINE RESPONSIBLE AGENTS

  • Organizational object: org unit, position, job, user (PPOME).
  • Expression: container element with an agent (e.g. &Approver& filled by a method).
  • Rule (PFAC):

– Responsibility rule: table of responsibilities by criteria (e.g. plant, cost center range → positions).
– Function-module rule: custom FM with container input returning actors (interface with AC_CONTAINER and ACTOR_TAB).

– Org-structure rules (e.g. manager of org unit).

━━━━━━━━━━━━━━━━━━━━
▶ 3. RULE FUNCTION MODULE

  • Reads criteria from the rule container (e.g. cost center), determines agents (e.g. from OM or a Z table), fills ACTOR_TAB with OTYPE 'US' + user or 'S' + position.
  • Raises NOBODY_FOUND if none — combined with "terminate if rule resolution without result", this puts the workflow into error instead of routing to all possible agents.

━━━━━━━━━━━━━━━━━━━━
▶ 4. SUBSTITUTES AND FORWARDING

  • Users define substitutes (SBWP) for absence; active or passive substitution with substitution profiles.
  • Admins can forward work items (SWIA) to other users.

━━━━━━━━━━━━━━━━━━━━
▶ 5. TESTING RULES

PFAC → "Simulate" with test container values; SWI1 log shows agents determined per step.

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. PFTC: check the possible agents of your approval task.
  2. PFAC: create a function-module rule (code example) and simulate it.
  3. Use the rule in the user decision step and set "terminate if rule resolution has no result".

✅ CHECKPOINT: you can configure agent determination safely with rules and understand recipient calculation.

Code example

ABAP Code
FUNCTION z_wf_rule_costcenter_mgr.*"----------------------------------------------------------------------*"  TABLES*"      AC_CONTAINER STRUCTURE  SWCONT*"      ACTOR_TAB STRUCTURE  SWHACTOR*"  EXCEPTIONS*"      NOBODY_FOUND*"----------------------------------------------------------------------  INCLUDE <cntn01>.                       " classic container macros   DATA: lv_kostl TYPE kostl,        lv_uname TYPE syuname. * ===== Step 1: read rule parameter from the rule container =====  swc_get_element ac_container 'CostCenter' lv_kostl. * ===== Step 2: determine the responsible user (example: custom mapping table) =====  SELECT SINGLE approver FROM zwf_kostl_appr INTO lv_uname    WHERE kostl = lv_kostl. * ===== Step 3: return agents or raise NOBODY_FOUND =====  IF sy-subrc = 0 AND lv_uname IS NOT INITIAL.    CLEAR actor_tab.    actor_tab-otype = 'US'.    actor_tab-objid = lv_uname.    APPEND actor_tab.  ELSE.    RAISE nobody_found.                   " with 'terminate if no result' -> error, not everyone  ENDIF.ENDFUNCTION. * ===== PFAC rule =====* Rule type: function to be executed -> Z_WF_RULE_COSTCENTER_MGR* Container element: CostCenter (KOSTL)* Step binding: &PurchaseRequisition.CostCenter& -> CostCenter* [x] Terminate if rule resolution without result * ===== Recipients = responsible (rule) ∩ possible (task) - excluded (e.g. &Requester&) =====

Real project scenario

After a reorganisation, a purchase requisition approval work item appeared in the inbox of 4,000 users. The task was a general task, and the rule found no approver for a new cost center — without "terminate if no result", the work item went to all possible agents.
The fix: mark the rule to terminate, maintain the new cost centers in the mapping, and restrict possible agents to an approver role. Unassigned cases now go to workflow administrators as errors instead of the whole company.

Common mistakes

  • General tasks combined with rules that can return nothing.
  • Hard-coded user IDs in templates.
  • Missing excluded agents (self-approval).
  • Rules not updated after reorganisations.
  • No simulation before transport.

Best practices

  • Restrict possible agents.
  • Rules with NOBODY_FOUND and terminate option.
  • Exclude requesters from approval steps.
  • Base rules on OM or maintained tables.
  • Simulate rules in PFAC and check logs.

Interview angle

Questions: "How are workflow agents determined?", "What is a general task?", "What happens if a rule finds nobody?"
Strong answer: recipients = responsible ∩ possible − excluded; responsible via org objects, expressions or PFAC rules (responsibility or FM rules with AC_CONTAINER/ACTOR_TAB and NOBODY_FOUND); general task = everyone possible; no result without terminate → all possible agents; substitutes, forwarding, PFAC simulation.

Practice this lesson

Quick check

1. A rule returns no agent for a general task, and "terminate if no result" is not set. What happens?

2. How are the actual recipients of a work item calculated?

3. What should a rule function module do when it finds no agent?

Interview questions

1. Describe the different agent determination strategies available in SAP Business Workflow and when you would use each one in an S/4HANA implementation.

Answer it in your own words first, then compare.

2. Purchase requisitions above a value threshold must be approved by the regional manager before release. How would you determine the approver?

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics