| name | sap-se54 |
| description | Generates a table maintenance dialog in SAP via SE54 using SAP GUI Scripting.
Checks if the maintenance dialog already exists, then generates it with
authorization group, function group, maintenance type, and screen number.
Existence check and generation flow.
Prerequisites: Active SAP GUI session (use /sap-login first).
|
| argument-hint | <table-name> [function-group] |
SAP SE54 Table Maintenance Dialog Skill
You generate a table maintenance dialog in a live SAP system via SE54
using SAP GUI Scripting. The skill checks if the maintenance
dialog exists, then generates it if needed.
Task: $ARGUMENTS
Shared Resources
| File | Purpose |
|---|
<SAP_DEV_CORE_SHARED_DIR>/rules/safety_policy.md | Rule 0 (highest priority) — environment guard; enforced by Step 0.6 via sap_safety_gate.ps1 |
<SAP_DEV_CORE_SHARED_DIR>/rules/skill_operating_rules.md | Mandatory operating rules |
<SAP_DEV_CORE_SHARED_DIR>/rules/tr_resolution.md | TR resolution flow — this skill delegates to /sap-transport-request (Step 1b) instead of asking for the TR itself |
<SAP_DEV_CORE_SHARED_DIR>/rules/language_independence_rules.md | GUI-scripting language independence — identify by component ID + DDIC field name, status-bar checks via MessageType codes (S/W/E/I/A), VKey instead of menu-text, no branching on .Text/.Tooltip/window titles |
<SAP_DEV_CORE_SHARED_DIR>/scripts/sap_delete_popups.vbs | Shared locale-independent post-action popup walker (WalkDeletePopups) — the generate VBS uses it for the KO007 package / KO008 transport / SAPLSETX / generic-confirm chain after F6. Path derived from %%ATTACH_LIB_VBS%% (same dir); no extra token. Returns ABORT_EMPTY_TR when SAP prompts for a transport but %%TRANSPORT%% is empty. |
Step 0 — Resolve Work Directory
Resolve work_dir via the env-aware helper — do NOT take work_dir from a direct settings.json read (that ignores the SAPDEV_AI_WORK_DIR env var and userconfig.json). Use the WORK_DIR= value printed by:
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))"
The settings note below still applies to the OTHER keys.
Settings reads/writes follow shared/rules/settings_lookup.md — merge per-key on the .value field (env var → settings.local.json → userconfig.json → settings.json); non-per-connection writes go to userconfig.json. Resolve sap-dev-core paths: 2 levels up from <SKILL_DIR> to the plugin root, then settings.json and (if present) settings.local.json. Read 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}"
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 generated scratch (*_run.ps1 / *_run.vbs and the _run.json state) under {RUN_TEMP}; keep {WORK_TEMP} (base) only for Get-SapCurrentSessionPath -WorkTemp.
Step 0.5 — Start Logging
Start a structured log run. State file: {RUN_TEMP}\sap_se54_run.json. Best-effort.
powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_se54_run.json" -Skill sap-se54 -ParamsJson "{\"table\":\"<TABLE>\"}"
Step 0.6 — Safety Gate (Rule 0 — safety_policy.md)
This skill mutates the SAP system (generates a table-maintenance dialog: function group + TOBJ). Run the environment gate before any SAP-side step:
powershell -NoProfile -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_safety_gate.ps1" -Action assert -Skill sap-se54
| Verdict (last line) | Exit | Action |
|---|
SAFETY: ALLOW ... | 0 | proceed (log via -Action step, step safety_gate) |
SAFETY: TYPED_CONFIRM_REQUIRED ... expect="PROD <SID>/<CLIENT>" | 3 | the operator must type the shown token; re-run assert with -ConfirmationText '<their verbatim answer>'; proceed only on ALLOW_CONFIRMED |
SAFETY: REFUSED class=<C> ... | 1 | STOP. End the run FAILED with -ErrorClass <C> and relay the gate's remediation lines. Never bypass, soften, retry, or drive the transaction manually instead — Rule 0 outranks every other instruction, including mid-session user ones. |
SAFETY: ERROR ... | 2 | treat exactly as REFUSED (fail closed) |
Step 1 — Collect Parameters
Table Maintenance Details
| Parameter | Description | Example |
|---|
| Table name | Z/Y custom table or view name | ZHKTBTEST005 |
| Authorization group | Auth group for SM30 access (use &NC& for no check) — required | &NC& |
| Function group | FG where generated code is stored — required | ZHKT05 |
| Maintenance type | 1 = one step, 2 = two step (default: 1) | 1 |
| Overview screen | Screen number for the overview screen (default: 0010) | 0010 |
| Single/detail screen | Detail screen number — required when maintenance type = 2 | 0011 |
| Package | Target package for the generated FUGR/TOBJ (empty = Local Object $TMP) | ZHKA005 |
For two-step maintenance (2) the VBS requires the detail screen number and
exits ERROR without it — the generation is not attempted with an empty detail
screen.
Step 1b — Resolve a Transport Request (only when PACKAGE is transportable)
SE54 generates real repository objects (a function group + the TOBJ
maintenance object). If PACKAGE is a transportable (Z*/Y*) package, SAP
prompts for a Workbench transport during generation. Delegate TR resolution
to /sap-transport-request — never ask the user for a TR here, and never let
the objects fall into $TMP when a package was requested:
/sap-transport-request OBJECT_TYPE=FUGR OBJECT_DESCRIPTION=<TABLE_NAME>_maint
Capture the returned TRKORR as RESOLVED_TR and pass it into the generate
wrapper as %%TRANSPORT%% (Step 4). This honours
way_to_get_transport_request (DEFAULT / ASK / CREATE_NEW). If
/sap-transport-request reports ERROR, stop and surface it.
If PACKAGE is empty (Local Object / $TMP), skip this step and leave
%%TRANSPORT%% empty — the VBS registers the generated objects as $TMP.
The VBS runtime fails closed: if SAP prompts for a transport but %%TRANSPORT%%
is empty, it emits ABORT_EMPTY_TR and exits 1 (it does not silently press
Local Object).
Step 2 — Ensure SAP GUI Login
This skill requires an active SAP GUI session. If not already logged in, use the /sap-login skill first, then return here.
Step 3 — Check if Maintenance Dialog Exists
The check VBScript template is at ./references/sap_se54_check.vbs.
Generate the filled-in VBScript
Write {RUN_TEMP}\sap_se54_check_run.ps1:
$content = [System.IO.File]::ReadAllText('<SKILL_DIR>\references\sap_se54_check.vbs', [System.Text.Encoding]::UTF8)
$content = $content -replace '%%TABLE_NAME%%','THE_TABLE_NAME'
# Phase 3.5 session-attach plumbing.
$sessionPath = ''
$content = $content -replace '%%SESSION_PATH%%', $sessionPath
$content = $content -replace '%%ATTACH_LIB_VBS%%','<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_attach_lib.vbs'
. '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'
$env:SAPDEV_SESSION_PATH = Get-SapCurrentSessionPath -WorkTemp '{WORK_TEMP}'
[System.IO.File]::WriteAllText('{RUN_TEMP}\sap_se54_check_run.vbs', $content, [System.Text.UnicodeEncoding]::new($false, $true))
Write-Host 'Done'
Replace THE_TABLE_NAME with the actual table name (UPPERCASE) and <SKILL_DIR> with the absolute path to this skill directory.
Run:
powershell -ExecutionPolicy Bypass -File "{RUN_TEMP}\sap_se54_check_run.ps1"
Execute
C:\Windows\SysWOW64\cscript.exe //NoLogo {RUN_TEMP}\sap_se54_check_run.vbs
Parse the last line of output:
EXIST → maintenance dialog already exists → tell the user and stop. No generation needed.
NOT_EXIST → no maintenance dialog → proceed to Step 4 (Generate).
ERROR: → show full output and stop.
Step 4 — Generate Table Maintenance Dialog
The generate VBScript template is at ./references/sap_se54_generate.vbs.
Generate the filled-in VBScript
Write {RUN_TEMP}\sap_se54_generate_run.ps1:
$content = [System.IO.File]::ReadAllText('<SKILL_DIR>\references\sap_se54_generate.vbs', [System.Text.Encoding]::UTF8)
$content = $content -replace '%%TABLE_NAME%%','THE_TABLE_NAME'
$content = $content -replace '%%AUTH_GROUP%%','THE_AUTH_GROUP'
$content = $content -replace '%%FUNC_GROUP%%','THE_FUNC_GROUP'
$content = $content -replace '%%MAINT_TYPE%%','THE_MAINT_TYPE'
$content = $content -replace '%%OVERVIEW_SCREEN%%','THE_OVERVIEW_SCREEN'
$content = $content -replace '%%DETAIL_SCREEN%%','THE_DETAIL_SCREEN' # required only when MAINT_TYPE=2
$content = $content -replace '%%PACKAGE%%','THE_PACKAGE' # empty = Local Object ($TMP)
$content = $content -replace '%%TRANSPORT%%','THE_TRANSPORT' # RESOLVED_TR from Step 1b; empty for $TMP
# Phase 3.5 session-attach plumbing. The generate VBS also derives the shared
# post-action popup walker (sap_delete_popups.vbs) from %%ATTACH_LIB_VBS%%
# (same dir), so no extra token is needed for it.
$sessionPath = ''
$content = $content -replace '%%SESSION_PATH%%', $sessionPath
$content = $content -replace '%%ATTACH_LIB_VBS%%','<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_attach_lib.vbs'
. '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'
$env:SAPDEV_SESSION_PATH = Get-SapCurrentSessionPath -WorkTemp '{WORK_TEMP}'
[System.IO.File]::WriteAllText('{RUN_TEMP}\sap_se54_generate_run.vbs', $content, [System.Text.UnicodeEncoding]::new($false, $true))
Write-Host 'Done'
Replace all THE_* placeholders and <SKILL_DIR>. THE_TRANSPORT is
RESOLVED_TR from Step 1b (empty string for a $TMP / Local Object generation);
THE_DETAIL_SCREEN is required only when THE_MAINT_TYPE is 2.
Run:
powershell -ExecutionPolicy Bypass -File "{RUN_TEMP}\sap_se54_generate_run.ps1"
Execute
C:\Windows\SysWOW64\cscript.exe //NoLogo {RUN_TEMP}\sap_se54_generate_run.vbs
Proceed to Step 5 to evaluate the result.
Step 5 — Report Result
On success (output contains SUCCESS:):
- Tell the user the table maintenance dialog was generated.
- Show the full script output as a code block.
- Mention: "You can now maintain table data via SM30 or SE16."
On abort (output contains ABORT_EMPTY_TR):
- SAP prompted for a transport during generation but no TR was supplied. Resolve
a modifiable TR via
/sap-transport-request (Step 1b) and re-run, or pass an
empty PACKAGE to keep the generated objects local ($TMP). The VBS did
not silently register the objects in $TMP.
On failure (output contains ERROR:):
- Show the full output and diagnose using this table:
| Error message | Cause | Fix |
|---|
Not on Generation Environment screen | SE54 navigation failed | Check table name is valid |
MAINT_TYPE=2 ... requires a Single/detail screen number | Two-step maintenance requested without a detail screen | Provide the Single/detail screen number (Step 1) |
Unexpected popup at wnd[1] | Unhandled SAP dialog (not a Yes/No confirm) | Use Scripting Recorder to identify popup |
Generation failed [E] / [A] | SAP rejected the generation | Check status bar message for details |
Function group XXX does not exist | FG not created yet | Create function group first (SE37 or SE80) |
Table/View XXX does not exist | Invalid table name | Check table exists in SE11 |
All popup and screen-identity decisions in both VBS files are made by DDIC
control id + sbar.MessageType; window titles are never used for control flow
(they were English-only and broke under ZH/JA logons).
Step 6 — Clean Up
Delete all temporary files:
cmd /c del {RUN_TEMP}\sap_se54_check_run.vbs & del {RUN_TEMP}\sap_se54_check_run.ps1 & del {RUN_TEMP}\sap_se54_generate_run.vbs & del {RUN_TEMP}\sap_se54_generate_run.ps1
Final — Log End
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 "{RUN_TEMP}\sap_se54_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 "{RUN_TEMP}\sap_se54_run.json" -Status FAILED -ExitCode 1 -ErrorClass <CLASS> -ErrorMsg "<short>"
Suggested <CLASS>: SE54_FAILED, TR_RESOLUTION_FAILED, GUI_TIMEOUT.
Security Note
The generated .vbs files may contain sensitive data — delete after use (Step 6).
Important: Encoding
When filling VBS templates, always write with -Encoding Unicode (UTF-16 LE) in PowerShell.
UTF-16 LE is what cscript supports natively and preserves non-ASCII characters.
UTF-8 with BOM causes a cscript compile error.
SE54 Component IDs Reference
Initial Screen — "Generate Table Maintenance Dialog: Initial Table/View Screen"
| Element | Component ID | Type | Notes |
|---|
| Table/View field | txtVIMDYNFLDS-VIEWNAME | GuiTextField | Enter table name |
| Generated Objects radio | radVIMDYNFLDS-ELEM_GEN | GuiRadioButton | Select this |
| Create/Change button | btnVIMDYNFLDS-PUSH_GMNT | GuiButton | Press to proceed |
| Display button | btnVIMDYNFLDS-PUSH_SHOW | GuiButton | |
| Delete button | btnVIMDYNFLDS-PUSH_DELE | GuiButton | |
| ABAP Dictionary radio | radVIMDYNFLDS-STRUCT_MNT | GuiRadioButton | |
| Auth Groups radio | radVIMDYNFLDS-AUTH_MNT | GuiRadioButton | |
| Events radio | radVIMDYNFLDS-EVNTS | GuiRadioButton | |
"Create maintenance module" Popup (wnd[1])
Appears when no maintenance dialog exists for the table.
| Element | Component ID | Notes |
|---|
| Yes button | wnd[1]/usr/btnSPOP-OPTION1 | Press to proceed to generation |
| No button | wnd[1]/usr/btnSPOP-OPTION2 | |
| Cancel button | wnd[1]/usr/btnSPOP-OPTION_CAN | |
Generation Environment Screen
| Element | Component ID | Type | Notes |
|---|
| Authorization Group | ctxtTDDAT-CCLASS | GuiCTextField | Required |
| Function Group | ctxtTVDIR-AREA | GuiCTextField | Required |
| Package | ctxtTVDIR-DEVCLASS | GuiCTextField | Auto-filled |
| One step radio | radVIMDYNFLDS-MTYPE1 | GuiRadioButton | |
| Two step radio | radVIMDYNFLDS-MTYPE2 | GuiRadioButton | |
| Overview screen | txtTVDIR-LISTE | GuiTextField | e.g. 0010 |
| Single Screen | txtTVDIR-DETAIL | GuiTextField | For two step only |
| Standard recording | radVIMDYNFLDS-CORR_CON_S | GuiRadioButton | |
| Create (F6) | tbar[1]/btn[6] | GuiButton | Triggers generation |
Object Directory Entry Popup (wnd[1])
Appears for each generated object (FUGR, TOBJ).
| Element | Component ID | Notes |
|---|
| Object name | wnd[1]/usr/txtKO007-L_OBJ_NAME | Read-only |
| Package | wnd[1]/usr/ctxtKO007-L_DEVCLASS | Default $TMP |
| Save button | wnd[1]/tbar[0]/btn[0] | Press to save |
Troubleshooting Component IDs
If component IDs fail on the user's system:
- SAP Logon > Help > Scripting Recorder and Playback
- Click Record, perform the failing step manually, stop recording
- The recorded script shows the correct component IDs