--- name: sap-ui-automation description: Uses SAP MCP tools to look up, check, create or change documents on live SAP screens, including VA03 order lookups, ALV lists and Fiori apps. Use for interactive SAP work or running an existing workflow with new inputs. --- # Work in SAP through MCP Use the tools exposed by the configured SAP server (for example, `sap-ui-automation:sap_look`). They act as the signed-in SAP user. ## Choose the task - **Work on the current screen.** Start with `sap_look`. If the user names a transaction and the target session is clean, open it with `sap_act` and `{"do":"okcode","value":"/nVA03"}`. A command submits itself. Starting a transaction with `/n` can discard unsaved input. - **Repeat a task.** Search `sap_library` with a few task keywords such as `sales order`. Use document numbers as run inputs. Read the required inputs and success check. Pass the chosen name, session and new values to `sap_workflow_run`, for example `{"name":"display-sales-order","session":"","variables":{"order":"004711"}}`. Preserve leading zeros. Use the named outputs from a passing run. For additional details on the final screen, call `sap_look` on the same session. If no workflow fits, work interactively. - **Save what worked.** Use the `sap-ui-workflow-authoring` skill. Read the original session’s `sap_history` with `includeSdk: true` and save the useful steps with `sap_workflow_save`. The library, save and run tools require `SAP_CODE_TOOLS=on`. - **Record a regression test.** On a clean test session, use `sap_record` to start, perform the steps, assert the expected result and stop. Find recorded tests with `sap_record {"op":"list"}` and repeat them with `sap_replay`. Recorded values and saved history evidence can include what was typed. ## Read and act Use control IDs from the current screen. Fill related fields together in `sap_act`, then press Enter once. Typing sets the value locally. Enter lets SAP validate it. Use F4 on a field to look up an unknown code. Read the screen returned by the action. Handle the frontmost popup first. If a batch stops, check which actions ran and continue from the displayed screen. A previous error may still be visible while you type a corrected value. Check the message again after Enter. Accept a warning with Enter only if it fits the task. For a grid, use `sap_look` with its ID and a row range before concluding an entry is missing. The initial screen shows visible rows. Interpret amounts using the session's `NUMBERS` line. If the notation is unknown, establish it before interpreting or entering an amount. ## Sessions and sign-in When several sessions are open, use `sap_sessions` to choose the intended system, client and user. Pass the exact ID on each call when working across sessions. To open an independent transaction, send `sap_act {"newSession":"VA03","session":""}` on its own. Verify the child session before using it. If SAP reports a session limit, inspect the source and list available sessions before trying another logon. If the intended system has no open session, use `sap_systems` and `sap_logon` when available. Otherwise ask the user to open SAP. If sign-in requires attention, relay SAP's message and let the user handle credentials. On Windows, prefer the scripting session when the same connection is also listed through the DIAG router. ## Writes and recovery Follow the user's configured write mode. Under `off`, actions that may write are refused. Under `on`, the default, they run: perform only the change the user requested. For a requested save, use `sap_act` with `{"do":"key","key":"Save"}` and report the resulting document number or SAP message. After a refusal or timeout, inspect the outcome before retrying. A submitted write may still finish. Report any unsaved edits or lock, respect the write setting, and discard only input you own or the user authorized you to discard.