From sap-tcd
Manages SAP material masters via MM01/MM02/MM03 using SAP GUI Scripting. Creates new materials or updates existing ones. Existence check (MM03 Display), material creation (MM01) with view/org-level handling, material update (MM02), and save. Field values are provided as tab-separated section/field/value triples in a definition file. Prerequisites: Active SAP GUI session (use /sap-login first).
How this skill is triggered — by the user, by Claude, or both
Slash command
/sap-tcd:sap-mm01 <material-number> [field-values-to-set]<material-number> [field-values-to-set]The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You manage SAP material masters via MM01 (Create), MM02 (Change), and MM03
You manage SAP material masters via MM01 (Create), MM02 (Change), and MM03 (Display) using SAP GUI Scripting. The skill checks if the material exists, then creates or updates it with the provided field values.
Task: $ARGUMENTS
Settings reads/writes follow <SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md — merge settings.local.json over settings.json per-key on the .value field; writes always go to settings.local.json. Resolve cross-plugin paths: 3 levels up from <SKILL_DIR>, then into sap-dev-core\settings.json and (if present) sap-dev-core\settings.local.json. Read work_dir, custom_url.
| Setting | Default if blank |
|---|---|
work_dir | C:\sap_dev_work |
custom_url | {work_dir}\custom |
Set {WORK_TEMP} = {work_dir}\temp
Ensure the temp directory exists:
cmd /c if not exist "{WORK_TEMP}" mkdir "{WORK_TEMP}"
Start a structured log run. State file: {WORK_TEMP}\sap_mm01_run.json. Best-effort.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{WORK_TEMP}\sap_mm01_run.json" -Skill sap-mm01 -ParamsJson "{\"material\":\"<MATNR>\"}"
Material Master Details
| Parameter | Description | Example |
|---|---|---|
| Material number | Material to create or update | ZHKMAT013 |
| Industry sector | Industry sector key (only for Create) | M |
| Material type | Material type key (only for Create) | FERT |
| Plant | Plant number | 1000 |
| Field values | Field values per view (see format below) | See Step 2 |
Industry Sector Keys:
| Key | Description |
|---|---|
M | Mechanical engineering |
C | Chemical industry |
P | Pharmaceuticals |
A | Plant engineering/construction |
Common Material Type Keys:
| Key | Description |
|---|---|
FERT | Finished Product |
HALB | Semifinished Product |
ROH | Raw Material |
HIBE | Operating supplies |
ERSA | Spare parts |
KMAT | Configurable materials |
The field definition file is a tab-separated text file that specifies which fields to fill in each material master view. Format:
SECTION<TAB>FIELD_NAME<TAB>VALUE
ORG for organizational levels, or tab panel ID (SP01–SP35) for view fieldsMARA-MEINS, MARC-DISMM)X/1 (checked) or empty/0 (unchecked)# are comments. Blank lines are skipped.Tab Panel IDs:
| Tab ID | View Name | Key Fields |
|---|---|---|
SP01 | Basic Data 1 | MAKT-MAKTX (Description), MARA-MEINS (Base UoM), MARA-MATKL (Material Group), MARA-SPART (Division), MARA-BRGEW (Gross Weight), MARA-GEWEI (Weight Unit), MARA-NTGEW (Net Weight) |
SP02 | Basic Data 2 | |
SP04 | Sales: Sales Org. 1 | MARA-SPART (Division) |
SP05 | Sales: Sales Org. 2 | |
SP06 | Sales: General/Plant | |
SP10 | Purchasing | MARA-BSTME (Order Unit), MARC-EKGRP (Purchasing Group) |
SP13 | MRP 1 | MARC-DISMM (MRP Type), MARC-DISPO (MRP Controller), MARC-DISLS (Lot Size), MARC-EKGRP (Purchasing Group) |
SP14 | MRP 2 | MARC-BESKZ (Procurement Type), MARC-LGPRO (Issue Storage Loc.), MARC-LGFSB (Default Storage Loc.), MARC-WEBAZ (GR Processing Time), MARC-DZEIT (In-House Production Time) |
SP15 | MRP 3 | |
SP16 | MRP 4 | |
SP20 | Work Scheduling | |
SP21 | Plant Data / Storage 1 | |
SP22 | Plant Data / Storage 2 | |
SP26 | Quality Management | |
SP27 | Accounting 1 | (nested tabstrip — accounting fields) |
SP28 | Accounting 2 | |
SP29 | Costing 1 | |
SP30 | Costing 2 |
Organizational Level Fields (ORG section):
| Field Name | Description | Example |
|---|---|---|
RMMG1-WERKS | Plant | 1000 |
RMMG1-LGORT | Storage Location | 1001 |
RMMG1-VKORG | Sales Organization | 1000 |
RMMG1-VTWEG | Distribution Channel | 10 |
RMMG1-BWTAR | Valuation Type |
Example definition file:
# Organizational levels
ORG RMMG1-WERKS 1000
# Basic Data 1
SP01 MAKT-MAKTX Test Material HK 013
SP01 MARA-MEINS PC
SP01 MARA-MATKL 0001
SP01 MARA-SPART 01
SP01 MARA-BRGEW 100
SP01 MARA-GEWEI KG
SP01 MARA-NTGEW 98
SP01 MARA-MTPOS_MARA NORM
# MRP 1
SP13 MARC-DISMM PD
SP13 MARC-DISPO 001
SP13 MARC-DISLS EX
SP13 MARC-EKGRP 101
# MRP 2
SP14 MARC-BESKZ E
SP14 MARC-LGPRO 1001
SP14 MARC-LGFSB 1001
SP14 MARC-WEBAZ 7
SP14 MARC-DZEIT 5
{WORK_TEMP}\<MATERIAL>_fields.txt
This skill requires an active SAP GUI session. If not already logged in, use the /sap-login skill first, then return here.
The check VBScript template is at ./references/sap_mm01_check.vbs.
Write {WORK_TEMP}\sap_mm01_check_run.ps1:
$content = Get-Content '<SKILL_DIR>\references\sap_mm01_check.vbs' -Raw
$content = $content -replace '%%MATERIAL%%','THE_MATERIAL'
Set-Content '{WORK_TEMP}\sap_mm01_check_run.vbs' $content -Encoding Unicode
Write-Host 'Done'
Replace THE_MATERIAL with the actual material number and <SKILL_DIR> with the absolute path to this skill directory.
Run:
powershell -ExecutionPolicy Bypass -File "{WORK_TEMP}\sap_mm01_check_run.ps1"
cscript //NoLogo {WORK_TEMP}\sap_mm01_check_run.vbs
Parse the last line of output:
EXIST → material exists → proceed to Step 5a (Update via MM02).NOT_EXIST → material does not exist → proceed to Step 5b (Create via MM01).ERROR: → show full output and stop.The update VBScript template is at ./references/sap_mm01_update.vbs.
Write {WORK_TEMP}\sap_mm01_update_run.ps1:
$content = Get-Content '<SKILL_DIR>\references\sap_mm01_update.vbs' -Raw
$content = $content -replace '%%MATERIAL%%','THE_MATERIAL'
$content = $content -replace '%%DEFINITION_FILE%%','THE_DEFINITION_FILE'
Set-Content '{WORK_TEMP}\sap_mm01_update_run.vbs' $content -Encoding Unicode
Write-Host 'Done'
Replace THE_MATERIAL, THE_DEFINITION_FILE (absolute path with backslashes), and <SKILL_DIR>.
Run:
powershell -ExecutionPolicy Bypass -File "{WORK_TEMP}\sap_mm01_update_run.ps1"
cscript //NoLogo {WORK_TEMP}\sap_mm01_update_run.vbs
Proceed to Step 6 to evaluate the result.
For creating a new material, you need the Industry Sector and Material Type. Ask the user if not already provided:
"This is a new material. Please provide the Industry Sector and Material Type."
The create VBScript template is at ./references/sap_mm01_create.vbs.
Write {WORK_TEMP}\sap_mm01_create_run.ps1:
$content = Get-Content '<SKILL_DIR>\references\sap_mm01_create.vbs' -Raw
$content = $content -replace '%%MATERIAL%%','THE_MATERIAL'
$content = $content -replace '%%INDUSTRY%%','THE_INDUSTRY'
$content = $content -replace '%%MATERIAL_TYPE%%','THE_MATERIAL_TYPE'
$content = $content -replace '%%DEFINITION_FILE%%','THE_DEFINITION_FILE'
$content = $content -replace '%%SESSION_LOCK_VBS%%','<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_session_lock.vbs'
Set-Content '{WORK_TEMP}\sap_mm01_create_run.vbs' $content -Encoding Unicode
Write-Host 'Done'
Replace all THE_* placeholders and <SKILL_DIR>.
Run:
powershell -ExecutionPolicy Bypass -File "{WORK_TEMP}\sap_mm01_create_run.ps1"
cscript //NoLogo {WORK_TEMP}\sap_mm01_create_run.vbs
Proceed to Step 6 to evaluate the result.
On success (output contains SUCCESS:):
On failure (output contains ERROR:):
| Error message | Cause | Fix |
|---|---|---|
does not exist or is not activated | Material not found (Update) | Create first or check material number |
Enter a material type | Missing material type (Create) | Provide material type and industry sector |
Failed to reach data screen | View/org level issue | Check org-level values (plant, sales org) |
Field not found | Field name mismatch | Verify ABAP field name for the target view |
Material creation failed | SAP validation error | Check status bar message, fix field values |
No SAP GUI session found | Not logged in | Run login step first |
Definition file not found | Wrong path | Verify file path and re-run Step 2 |
Package/transport dialog | Needs transport assignment | Handled automatically ($TMP) |
Delete all temporary files (including the field definition file):
cmd /c del {WORK_TEMP}\sap_mm01_check_run.vbs & del {WORK_TEMP}\sap_mm01_check_run.ps1 & del {WORK_TEMP}\sap_mm01_create_run.vbs & del {WORK_TEMP}\sap_mm01_create_run.ps1 & del {WORK_TEMP}\sap_mm01_update_run.vbs & del {WORK_TEMP}\sap_mm01_update_run.ps1 & del {WORK_TEMP}\*_fields.txt
Log the run-end record. Best-effort.
On success:
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{WORK_TEMP}\sap_mm01_run.json" -Status SUCCESS -ExitCode 0
On failure:
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action end -StateFile "{WORK_TEMP}\sap_mm01_run.json" -Status FAILED -ExitCode 1 -ErrorClass <CLASS> -ErrorMsg "<short>"
Suggested <CLASS>: MM01_FAILED, GUI_TIMEOUT.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub sapdev-ai/sap-dev --plugin sap-tcd