Skip to content
Development
Skill

/sap-tcd-chain

Drives a complete headless O2C business-document chain — sales order → outbound delivery → goods issue → billing — over RFC BAPIs, so regression testing gets whole document flows, not isolated documents. Each step is created via its SAP write BAPI, committed (WAIT='X'), and

From plugin
sap-dev
8123 skills3 agents
Install
$ npx -y skills add sapdev-ai/sap-dev --skill sap-tcd-chain --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/sap-tcd-chain

Context preview

The summary Claude sees to decide when to auto-load this skill.

Drives a complete headless O2C business-document chain — sales order → outbound delivery → goods issue → billing — over RFC BAPIs, so regression testing gets whole document flows, not isolated documents. Each step is created via its SAP write BAPI, committed (WAIT='X'), and

SKILL.md

sap-tcd-chain.SKILL.md
name: sap-tcd-chain
description: |
  Drives a complete headless O2C business-document chain — sales order → outbound
  delivery → goods issue → billing — over RFC BAPIs, so regression testing gets whole
  document flows, not isolated documents. Each step is created via its SAP write BAPI,
  committed (WAIT='X'), and VBFA-verified before the next step (VBTYP_N J=delivery,
  R=goods issue, M=billing) — success is never trusted from the BAPI echo. Stops on
  the first failure and dumps the verbatim BAPIRET2 (a blocked step is almost always a
  customizing problem — the message IS the deliverable), writing an auditable chain
  manifest that `status` re-verifies and phase-2 `reset` reverses. `--dry-run`
  TESTRUN-simulates the order + preflights master data with zero writes. Pure RFC (all
  v1 FMs remote-enabled on S/4HANA 1909 + ECC 6) — no GUI, no Z objects, no transports;
  VBUK is never read (dead on S/4 for new docs). Prerequisites: SAP profile via
  /sap-login (RFC) with SD posting authorization; SAP NCo 3.1 (32-bit).
argument-hint: "run o2c --scenario <file> [--from-order <VBELN>] [--stop-after order|delivery|gi|billing] [--dry-run] | status <VBELN|manifest>"

SAP O2C Chain Skill

You drive an order-to-cash document chain headlessly, **verifying each step against VBFA before the next**, and stop cleanly with the verbatim BAPIRET2 when config blocks a step. You never continue past a failed or unverified step.

Task: $ARGUMENTS

---

Shared Resources

| File | Token / call | Purpose | |---|---|---| | `<SAP_DEV_CORE_SHARED_DIR>/rules/safety_policy.md` + `<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_safety_gate.ps1` | Rule 0 | Environment guard — Step 4 runs `-Action assert` before the write | | `<SKILL_DIR>/references/sap_tcd_chain_rfc.ps1` | `-Action preflight\|create-order\|create-delivery\|post-gi\|create-billing\|verify-flow` | BAPI chain + VBFA verify | | `<SKILL_DIR>/references/scenario_o2c_sample.txt` | template | Commented scenario-file sample | | `<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_artifact_lib.ps1` | dot-sourced | Chain manifest + evidence registration | | `/sap-login` | sub-skill | Pinned RFC profile | | `/sap-bp` · `/sap-mm01` | sub-skills | Pointed to in preflight failures (never auto-invoked) |

Scenario file: tab-delimited `SECTION<TAB>FIELD<TAB>VALUE` — `ORDER_HEADER` (DOC_TYPE, SALES_ORG, DISTR_CHAN, DIVISION), `ORDER_PARTNERn` (ROLE=AG sold-to, NUMBER), `ORDER_ITEM_NN` (MATERIAL, QTY), `DELIVERY` (SHIP_POINT), `BILLING`.

---

Step 0 — Directories + Logging

Resolve `work_dir` + `{RUN_TEMP}` (canonical one-liner — `sap_connection_lib.ps1` is dot-sourced there — with `Write-Output ('RUN_TEMP=' + (Get-SapRunTemp))` appended). `{RUN_TEMP}` = the per-run scratch dir holding the log state file; mint it once here and reuse (re-minting breaks the `-Action end` state-file lookup). Start logging (`sap_log_helper.ps1`, state `{RUN_TEMP}\sap_tcd_chain_run.json`). RFC-only — no GUI session.

Step 1 — Parse & Dispatch

Modes: `run o2c` (+ `--dry-run`, `--from-order`, `--stop-after`), `status`. Phase-2 (`reset`, `run p2p`) → say not implemented, cite the roadmap. Validate the scenario file locally first.

Step 2 — RFC Profile

Pinned RFC profile required (`/sap-login`) — no GUI fallback in v1; missing profile → `RFC_LOGON_FAILED`, STOP.

Step 3 — `--dry-run` (zero SAP writes)

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "<SKILL_DIR>\references\sap_tcd_chain_rfc.ps1" -Action preflight -Scenario "<file>" -SharedDir "<SAP_DEV_CORE_SHARED_DIR>"

Then `-Action create-order -Scenario <file> -TestRun X` — a genuine server-side simulate (`BAPI_SALESORDER_CREATEFROMDAT2 TESTRUN`) with zero persistence. Render the `STEP:` + `BAPIRET:` lines. `--dry-run` stops here (report the verdict). `SCENARIO_INVALID` (missing sold-to / item / org) → show the offending lines, STOP.

Step 4 — Confirm Gate (`run o2c`, mandatory)

**Rule 0 first** (`safety_policy.md`; `run o2c` (non-dry-run) only — `--dry-run` and `status` skip it): `powershell -NoProfile -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_safety_gate.ps1" -Action assert -Skill sap-tcd-chain` — `SAFETY: ALLOW` (0) proceed; `TYPED_CONFIRM_REQUIRED` (3) -> the operator types the shown `PROD <SID>/<CLIENT>` token, re-run with `-ConfirmationText '<their verbatim answer>'`, proceed only on `ALLOW_CONFIRMED`; `REFUSED class=<C>` (1) / `ERROR` (2) -> **STOP**, end `FAILED` with `-ErrorClass <C>`, relay the remediation lines — never bypass or work around it manually. The yes/no gate below still applies after ALLOW/ALLOW_CONFIRMED.

State it and get a yes/no:

> I will create a real O2C chain in `<SID>/<CLIENT>`: order (`<DOC_TYPE>`, sold-to > `<AG>`, `<n>` items) → delivery → goods issue → billing. This writes real documents. > Proceed? (yes/no)

Decline → log `SKIPPED`, STOP (zero documents).

Step 5 — Drive the Chain (verified, stop-on-first-failure)

Run the steps in order, threading each step's key into the next (`create-order` → `-Order <VBELN>` → `create-delivery` → `-Delivery <VBELN>` → `post-gi` / `create-billing`). `--from-order <VBELN>` skips step 1. Honor `--stop-after`.

Each backend action: calls the BAPI → COMMIT (WAIT='X') → **VBFA verify** (with a 0/1/2/4s backoff for V2-update lag) → prints `STEP: <name> OK key=<doc>`. On failure:

  • `STEP_FAILED` → the BAPI returned E/A; the transaction was **rolled back**; the

`BAPIRET:` lines are the deliverable (almost always customizing: shipping point, copy control, division/text, picking relevance). Finalize the manifest PARTIAL, STOP.

  • `VERIFY_FAILED` → the BAPI "succeeded" but no VBFA successor row appeared — a false

success; STOP (`TCD_CHAIN_VERIFY_FAILED`). Never render it as done.

Step 6 — Manifest + Register (you assemble it)

Write `chain_manifest.json` (schema `sapdev.tcdchain/1`) into the artifact dir (`Get-SapArtifactDir -ScopeKey TCDCHAIN_<SID>_<CLIENT>_<order>`) from the `STE

Read more
Ships withsap-dev

SAP development automation skills for AI coding assistants. Windows-only — the skills drive SAP GUI for Windows via GUI Scripting (plus optional RFC via SAP NCo); there is no macOS/Linux path.

Get the whole plugin

Other skills on sap-dev.