/sap-migrate:sap-cc-usage --campaign <id> [--usage-source FILE|SCMON|UPL|WORKLOAD|NONE] [--usage-file <path>] [--source-profile <ref>] [--namespaces Z,Y] [--policy none|conservative|aggressive] [--min-exec 0] [--force-low-join] [--workload-months 12]from sap-migrate
Overlays SAP runtime usage data onto custom code inventory to decide remediation vs retirement, producing scope files with decommission/review decisions.
Ships in sap-migrate. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You decide, for every inventoried custom object, whether it should be remediated, retired (decommissioned), or reviewed — by overlaying how often it actually runs. Retiring dead code is usually the single biggest scope reduction in a conversion, so this step's savings number matters.
Task: $ARGUMENTS
| File | Token | Purpose |
|---|---|---|
<SAP_DEV_CORE_SHARED_DIR>/rules/skill_operating_rules.md | (rule) | Mandatory operating rules. |
<SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md | (rule) | Settings / work_dir resolution. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_settings_lib.ps1 + sap_connection_lib.ps1 | (dot-source) | Get-SapWorkDir. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_log_helper.ps1 | (invoke) | Start/step/end JSONL logging. |
<SKILL_DIR>/references/sap_cc_usage.ps1 | (invoke) | Joins usage onto inventory, applies the policy, writes usage.tsv + scope.tsv, advances state.tsv. Emits parseable USAGE: / DECISION: / METRIC: / STATUS: lines. Offline (files only). |
<SKILL_DIR>/references/sap_cc_scmon_read.ps1 | (invoke, RFC) | Direct SCMON/UPL reader (SCMON/UPL source only). Reads the source system's SUSG_V_DATA (aggregated) / SCMON_VDATA (raw) + SUSG_ADMIN (window) via RFC and writes a usage export TSV. Emits SCMON: / WINDOW_WARN: / EXPORT: / STATUS: OK|NO_DATA|ERROR. |
<SKILL_DIR>/references/sap_cc_workload_read.ps1 | (invoke, RFC) | Workload fallback reader (WORKLOAD source only) for systems without SCMON. Reads the ST03N workload monitor via SWNC_GET_WORKLOAD_STATISTIC (TCDET per-entry counts) over the last N months, resolves Z/Y tcodes to programs via TSTC, and writes the same usage export TSV. Positive-only, LOW-confidence. Emits WORKLOAD: / WINDOW_WARN: / EXPORT: / STATUS: OK|NO_DATA|ERROR. |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_rfc_lib.ps1 + sap_dpapi.ps1 | (used by the reader) | NCo 3.1 connect + source-profile password decrypt (SCMON/UPL path only). |
/sap-where-used-list | (skill) | Used in the reference-safety check (Step 4) to confirm a REVIEW candidate has no inbound callers among still-used objects before it is decommissioned. |
The workspace contract (usage.tsv / scope.tsv columns, the
SCOPED / DECOMMISSIONED / REVIEW states, the upsert rule) is defined by
/sap-cc-campaign. This skill owns usage.tsv and scope.tsv.
The scoping helper (
sap_cc_usage.ps1) and the FILE/NONE paths are offline — no SAP GUI, broker, attach lib, or TR. Two parts touch SAP, both read-only: the SCMON/UPL reader (RFC against thesource_profile, Step 1.5) and the optional reference-safety check (Step 4, via/sap-where-used-list).
powershell -NoProfile -ExecutionPolicy Bypass -Command ". '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_settings_lib.ps1'; . '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'; Write-Output ('WORK_DIR=' + (Get-SapWorkDir))"
Set {WORK_TEMP} = {work_dir}\temp (create if needed) and
{CAMPAIGN_DIR} = {work_dir}\migrations\{campaign-id}.
Set {RUN_TEMP} = the per-run scratch dir (Get-SapRunTemp mints + creates
{work_dir}\temp\run_<id>):
powershell -NoProfile -ExecutionPolicy Bypass -Command ". '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'; Write-Output ('RUN_TEMP=' + (Get-SapRunTemp))"
Per the CLAUDE.md "Two-bucket temp model" write this skill's per-run scratch
(the log state file below) under {RUN_TEMP}, never at a fixed name under the
{WORK_TEMP} root.
State file: {RUN_TEMP}\sap_cc_usage_run.json. Best-effort.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_cc_usage_run.json" -Skill sap-cc-usage -ParamsJson "{}"
--campaign <id> — required. Need both {CAMPAIGN_DIR}\campaign.json and
a populated inventory.tsv. If inventory is missing/empty, stop and tell the
operator to run /sap-cc-inventory first.--usage-file <path> — the usage export (FILE source). Recommended format:
TSV/CSV, col1 = object name, col2 = exec count, optional col3 = last
used; a header row is auto-detected. A single-column file (just names) is
treated as "present = used".--usage-source FILE|SCMON|UPL|WORKLOAD|NONE — defaults to FILE when
--usage-file is given, else NONE.
FILE — ingest the --usage-file export (offline).SCMON / UPL — read usage directly from the source system (Step 1.5):
run sap_cc_scmon_read.ps1 over RFC, then ingest its export. On NW 7.52+/S4
SCMON subsumes UPL, so both read the same SUSG/SCMON path. Preferred —
SCMON/SUSG is the canonical decommissioning source.WORKLOAD — fallback when SCMON was never activated (Step 1.5b): run
sap_cc_workload_read.ps1 over RFC to read the ST03N workload monitor. This
is a coarse, positive-only, LOW-confidence signal — it confirms which
custom reports/tcode-programs ran but cannot prove anything unused, so it
never auto-decommissions (see the policy table). Use it to narrow the
decommission hunt, not to decide deletions.NONE — no usage data; every object → REMEDIATE (safe).--source-profile <ref> — (SCMON/UPL/WORKLOAD) connection profile of the
system whose usage to read; defaults to the campaign's source_profile, else
the pinned /sap-login connection.--namespaces <list> — (SCMON/UPL/WORKLOAD) OBJ_NAME prefixes to read,
default Z,Y. Add customer namespaces (e.g. Z,Y,/ACME/) for non-Z/Y custom
code.--workload-months <n> — (WORKLOAD) how many months of ST03N aggregates to
sum (default 12). Longer widens coverage but the collector's retention caps it.--policy none|conservative|aggressive — defaults to the brief's
scope.decommission_policy, else conservative.--min-exec <n> — "used" means exec_count > n (default 0).--force-low-join — accept a usage file whose join rate (share of
inventory objects it matches) is below 10%. Without it, such a file is
rejected (USAGE_JOIN_LOW) because a low join usually means a wrong-system
or wrong-format export, and flagging the rest of the estate "unused" from it
would be dangerous. A file matching ZERO inventory objects is always rejected
(USAGE_JOIN_ZERO) — this flag does not override that.--usage-source SCMON|UPL)Skip this step for FILE / NONE. For SCMON/UPL, read usage from the source system first, then feed the result into Step 2.
Run the reader via 32-bit PowerShell (SAP NCo 3.1 is in the 32-bit GAC):
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "<SKILL_DIR>\references\sap_cc_scmon_read.ps1" -CampaignDir "{CAMPAIGN_DIR}" -WorkDir "{work_dir}"
Append -SourceProfile "<ref>" and/or -Namespaces "Z,Y,/ACME/" to mirror the
flags. The reader writes {CAMPAIGN_DIR}\usage_scmon_export.tsv. Parse its last
STATUS: line:
STATUS: | Meaning | Action |
|---|---|---|
OK | Usage read; export written (EXPORT: line). | Proceed to Step 2 with -UsageSource SCMON -UsageFile {CAMPAIGN_DIR}\usage_scmon_export.tsv. |
NO_DATA | SCMON/SUSG empty — monitoring not active/aggregated. | Do NOT decommission anything. Surface the WARN: to the operator, then run Step 2 with -UsageSource NONE (every object → REMEDIATE). Recommend activating SCMON (tx SCMON) + aggregating via SUSG for ≥ 12 months. |
ERROR | RFC/profile failure (see the ERROR: line). | Fix the connection (/sap-login) or fall back to a manual --usage-file export. |
Always surface any WINDOW_WARN: line. It means the observation window is
short (or has gaps) — unused-flagging will over-decommission because period-end /
quarter-end / year-end jobs fall outside the window. When you see it, advise the
operator to treat DECOMMISSION candidates as REVIEW until a ≥ 12-month window is
available (and prefer conservative policy, which already parks them as REVIEW).
--usage-source WORKLOAD)Use this only when SCMON is unavailable (Step 1.5 returned NO_DATA, or the system is a pre-7.50 / never-activated box). Run the workload reader via 32-bit PowerShell:
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File "<SKILL_DIR>\references\sap_cc_workload_read.ps1" -CampaignDir "{CAMPAIGN_DIR}" -WorkDir "{work_dir}"
Append -SourceProfile "<ref>", -Namespaces "Z,Y,/ACME/", and/or -Months 12
to mirror the flags. It writes {CAMPAIGN_DIR}\usage_workload_export.tsv. Parse
its last STATUS: line:
STATUS: | Meaning | Action |
|---|---|---|
OK | Workload read; export written. | Proceed to Step 2 with -UsageSource WORKLOAD -UsageFile {CAMPAIGN_DIR}\usage_workload_export.tsv. |
NO_DATA | ST03N/SWNC has no custom-code entries in the window. | Run Step 2 with -UsageSource NONE (every object → REMEDIATE). Consider activating SCMON for a real decommissioning signal. |
ERROR | RFC/profile failure (see ERROR:). | Fix the connection (/sap-login). |
The reader always emits a WINDOW_WARN restating that WORKLOAD is coarse and
positive-only. Surface it. WORKLOAD's job is to confirm which custom
executables definitely ran (so you focus decommission-hunting elsewhere), never
to justify a deletion.
powershell -ExecutionPolicy Bypass -File "<SKILL_DIR>\references\sap_cc_usage.ps1" -CampaignDir "{CAMPAIGN_DIR}"
Append any of -UsageFile "<path>", -UsageSource FILE|SCMON|UPL|WORKLOAD|NONE,
-Policy conservative, -MinExec 0, -ForceLowJoin to mirror the flags. For the SCMON/UPL
path, pass -UsageSource SCMON -UsageFile {CAMPAIGN_DIR}\usage_scmon_export.tsv
(the Step 1.5 export) — the helper ingests it but stamps usage_source=SCMON in
usage.tsv for provenance. For WORKLOAD, pass
-UsageSource WORKLOAD -UsageFile {CAMPAIGN_DIR}\usage_workload_export.tsv (the
Step 1.5b export). The scoping helper itself needs no NCo (the RFC work is done
in Step 1.5 / 1.5b).
Policy semantics:
| Policy | used (exec > min) | unused | no usage data |
|---|---|---|---|
none | REMEDIATE | REMEDIATE | REMEDIATE |
aggressive | REMEDIATE | DECOMMISSION (no reference check) | REMEDIATE |
conservative (default) | REMEDIATE | REVIEW (pending reference check) | REMEDIATE |
WORKLOAD source overrides the "unused" column (positive-only, LOW-confidence):
regardless of policy, an object not seen in the ST03N window is UNKNOWN →
REMEDIATE if it is a class / FM / table / structure (workload never lists
those), or REVIEW if it is a PROG (a weak unused candidate) — never
DECOMMISSION. Only SCMON/SUSG or FILE usage can drive aggressive →
DECOMMISSION. This is enforced in the engine, not just documented.
USAGE_JOIN: matched=<j> inventory=<n> rate=<pct>%
USAGE: source=<src> policy=<p> min_exec=<n> matched=<j> file=<path>
USED: <n> | UNUSED: <n> | UNKNOWN: <n>
DECISION: REMEDIATE | COUNT: <n>
DECISION: DECOMMISSION | COUNT: <n>
DECISION: REVIEW | COUNT: <n>
METRIC: decommission_savings_pct | VALUE: <n>
SCOPE: wrote <path>
STATUS: OK | EMPTY | ERROR
USAGE_JOIN: is the join-rate guard (always printed): matched counts the
inventory objects the usage data actually matched (join hits — NOT
usage-file rows; the USAGE: line's matched= is the same join-hit count).
When a usage file was ingested and matched=0, the helper stops with
STATUS: ERROR USAGE_JOIN_ZERO (...) and exit 2 without writing anything
— a wrong-system/wrong-format export must never mark the estate unused. A join
rate below 10% likewise stops with STATUS: ERROR USAGE_JOIN_LOW (...) unless
-ForceLowJoin is passed.
| Exit | Meaning |
|---|---|
0 | STATUS: OK — usage.tsv + scope.tsv written, state.tsv advanced. |
1 | STATUS: EMPTY — inventory empty/missing (run /sap-cc-inventory). |
2 | STATUS: ERROR — bad workspace / usage file / policy, or the join guard fired (USAGE_JOIN_ZERO / USAGE_JOIN_LOW: nothing written — verify the usage export comes from THIS campaign's source system, or pass --force-low-join only after confirming a genuinely small overlap). |
Report the REMEDIATE / DECOMMISSION / REVIEW split, the join rate, and the savings %.
This is the human/where-used gate that turns REVIEW candidates into safe
DECOMMISSION decisions. For conservative runs, before any REVIEW object is
retired, confirm nothing still calls it:
/sap-where-used-list <object>.scope.tsv), it is safe to retire → the operator promotes it
to DECOMMISSION.v1 performs this gate manually / operator-driven (the helper parks unused objects as REVIEW and never deletes without it). Automating the batch promotion (a
--apply-referencespass over the cross-reference index) is the next increment — see Limitations.
After any promotions, re-run /sap-cc-campaign report to refresh the dashboard.
{CAMPAIGN_DIR}\usage.tsv — obj_name · obj_type · exec_count · last_used_on · usage_source · used_flag (this skill owns it).{CAMPAIGN_DIR}\scope.tsv — obj_name · obj_type · decision · reason · referenced_by_used (this skill owns it).{CAMPAIGN_DIR}\state.tsv — decisions set; INVENTORIED objects advanced to SCOPED / DECOMMISSIONED / REVIEW.{CAMPAIGN_DIR}\usage_scmon_export.tsv — (SCMON/UPL source only) the raw export the reader produced from the source system's Call Monitor; kept as evidence of what usage was read.{CAMPAIGN_DIR}\usage_workload_export.tsv — (WORKLOAD source only) the export the workload reader produced from the ST03N/SWNC aggregates; kept as evidence.--usage-source SCMON|UPL now reads
the source system's ABAP Call Monitor / SUSG aggregation over RFC
(sap_cc_scmon_read.ps1 → SUSG_V_DATA aggregated, SCMON_VDATA raw
fallback, SUSG_ADMIN for the window). Caveats:
WINDOW_WARN when the window is < 12 months or has
gaps; prefer conservative policy until a long window exists. Verified live
on S/4HANA 1909: connect + the empty-data safe path (NO_DATA → REMEDIATE).--usage-file.--usage-source WORKLOAD reads ST03N/SWNC (SWNC_GET_WORKLOAD_STATISTIC →
TCDET, summed over --workload-months) when SCMON is unavailable. Caveats:
aggressive DECOMMISSION (engine-enforced). Use it to confirm what
ran and narrow the hunt, not to decide deletions.TSTC; a Z/Y
ENTRY_ID that is itself a report is used directly. A tcode pointing at an SAP
(non-custom) program is ignored. Function-level detail is not available.STATUS: NO_DATA → REMEDIATE
(safe). The positive-mapping path is offline-unit-tested (unseen PROG →
REVIEW, invisible CLAS/TABL → REMEDIATE, zero DECOMMISSION under aggressive);
exercise it live on a workload-populated system to confirm TCDET field names.conservative parks unused
objects as REVIEW; promoting them to DECOMMISSION via /sap-where-used-list
is operator-driven (Step 4). The automated batch promotion is the next
increment. aggressive decommissions unused objects without this check —
use only when you accept that risk.USAGE_JOIN_ZERO), and a join rate < 10% requires --force-low-join
(USAGE_JOIN_LOW) — both before any file is written. This blocks the
wrong-system/wrong-format export from silently flagging the estate unused.powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{RUN_TEMP}\sap_cc_usage_run.json" -Status SUCCESS -ExitCode 0
For exit 1 use -Status SKIPPED -ExitCode 1 -ErrorClass CC_USAGE_NO_INVENTORY;
for exit 2 use -Status FAILED -ExitCode 2 -ErrorClass CC_USAGE_BAD_INPUT.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
sap, custom-code-migration, decommission, usage-analysis, scmon, abap
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-migrate10 skills in this plugin
/sap-cc-analyzeRuns the S/4HANA-readiness ATC over a migration campaign's REMEDIATE objects and
captures per-finding results into findings/findings_raw.tsv, advancing each
object to ANALYZED. The ATC run is delegated to /sap-atc
--variant=S4HANA_READINESS (so this skill ships no new GUI scripting; /sap-atc
fails loud if that variant can't be located on the release, so a non-readiness
run is never passed off as readiness). Two actions: `prepare` builds the
worklist from scope.tsv; `ingest` parses ATC result exports (from /sap-atc or a
manual "Manage Results" export — header-tolerant) into the findings ledger and
advances state. Run after /sap-cc-usage, before /sap-cc-triage.
Prerequisites: the connected system offers the S4HANA_READINESS variant with the
Simplification Database loaded; /sap-atc working (its per-stage recordings
target the S/4HANA 1909 ATC layout — re-record a failing stage with
/sap-gui-probe --record).
/sap-cc-campaignOwns the S/4HANA custom-code migration campaign workspace and is the
orchestration entry point for the sap-migrate engine. Five subcommands:
init — create a campaign workspace from the migration Customer Brief
(source/target release, in-scope packages, decommission policy,
connection profiles, human gates) + the empty state ledger.
status — per-state / per-tier counts + headline metrics.
report — render reports/dashboard.md: state/tier/pattern rollup + five KPIs
(decommission savings, ATC-clean rate, auto-fix rate, unmatched-finding
backlog, business sign-off); every percentage honest ("n/a", not 0%,
when the ledger isn't produced yet).
next — recommend the next pipeline skill, honouring the human-approval gates.
signoff— record a business-owner sign-off in campaign.json.
Pure workspace/state/reporting skill — OFFLINE (no SAP GUI, no RFC, no NCo); it
only reads/writes the campaign files the other sap-cc-* skills produce.
Prerequisites: none (the downstream skills it sequences do need SAP access).
/sap-cc-cloud-readinessMeasures each custom (Z/Y) object's DISTANCE FROM ABAP CLOUD — the question
S4HANA_READINESS (/sap-cc-analyze) does not answer. `scan` downloads source over
RFC for a campaign's REMEDIATE scope (or an explicit --objects/--packages set),
matches a versioned forbidden-statement ruleset + a cloudification-repository
snapshot offline, and classifies every object TIER_1_READY / TIER_2_WRAPPABLE
(only blockers are unreleased APIs with a successor) / TIER_3_CLASSIC (a
forbidden statement or an unreleased API with no successor), with a per-blocker
blockers.tsv and an AI summary of the cheapest wins. Honest by construction: an
API absent from the pack is 'unknown' (counted, never a blocker), a source that
can't be read is COULD_NOT_CHECK (never TIER_1), and any dynamic call sets
dynamic_blindspot=YES. S/4-ONLY (hard-refuses a non-S/4 pinned profile —
CC_NOT_S4 — pointing to /sap-cc-analyze). Read-only RFC; no writes, no TR, no
deploy. Prerequisites: /sap-login pinned to the S/4 system; SAP NCo 3.1 (32-bit).
/sap-cc-decommissionEXECUTES the retirement of unused custom objects a campaign flagged for
decommission — turning "40-60% of custom code is unused" into a realized,
audited deletion. /sap-cc-usage only FLAGS; this skill physically deletes,
behind a hard signed gate and a per-object safety chain. Two actions: `plan`
(behind the decommission_signoff gate — build the retirement worklist from
scope.tsv, consumers before providers; nothing deleted) and `record` (after the
delegated deletes, advance state + append the decommissioned.tsv audit ledger).
Per object it re-verifies safety (no inbound callers, still resolves, not locked
in another TR), backs up the source, resolves a TR, deletes via the routed
workbench skill, and CONFIRMS it is physically gone before ledgering. Irreversible
and transported to QA/PROD — never deletes without the sign-off, never ledgers an
object it didn't confirm gone. Run after /sap-cc-usage.
Prerequisites: scope.tsv with DECOMMISSION rows; SAP NCo 3.1 (32-bit); the
source connection.
/sap-cc-inventoryEnumerates and classifies the custom (Z/Y / customer-namespace) repository
objects in scope for an S/4HANA migration campaign. Reads TADIR + TRDIR over
read-only RFC against the campaign's SOURCE system, writes inventory.tsv, and
upserts every object into the state ledger as INVENTORIED (never touching
objects further along, so it is safe to re-run as new custom code appears). No
SAP GUI, no writes, no TR — pure read-only. First SAP-touching step of the
sap-migrate pipeline; run after /sap-cc-campaign init, before /sap-cc-usage.
When RFC is blocked, --source-mode GUI ingests /sap-se16n exports of TADIR
(+ TRDIR) instead (identical output, no NCo). Scope defaults to the brief's
in_scope_packages; override with --namespace / --packages / --types / --exclude.
Prerequisites (RFC): SAP NCo 3.1 (32-bit) + a saved source_profile (or pinned
/sap-login). GUI mode needs only a SAP GUI session for the /sap-se16n export.
/sap-cc-remediateRemediates a migration campaign's TRIAGED R1 (mechanical) objects on the
SANDBOX — the only sap-migrate skill that changes SAP, and only after a
mandatory dry-run review. Four actions:
apply — dry-run the deterministic R1 rule pack over each object's source →
<obj>.after.abap + diff for the operator to review (this is the gate).
assist — R2/R3: assemble a per-object AI context bundle for a recipe-faithful
rewrite (never auto-applied; DRAFT patterns advisory-only).
revert — roll a deployed fix back to its retained before-image (confirmed).
record — after the operator deploys the approved fix + ATC re-check, advance
campaign state (TRIAGED → REMEDIATED → VERIFIED).
R1 is deterministic; R2/R3 and unclassified '?' objects are AI-assisted / human
work, never auto-applied. Run after /sap-cc-triage.
Prerequisites: downloaded source per R1 object; deploy via the workbench skills
on the sandbox.
Other plugins' skills for the same job