Sap webgui

From marcellourbani/vscode_abap_remote_fs · View interactive version

Sap webgui is an AI agent skill from the GitHub repository marcellourbani/vscode_abap_remote_fs. Authoritative SAP WebGUI behavior and locator guidance for live exploration and Playwright script generation. Covers iframes, accessible names, generated IDs, selection screens, dialogs, ALV grids, toolbars, uploads, themes, and known SapSession helper limitations. Load before explore-ui live explor

How to use this skill

Skill file

SAP WebGUI — UI Mechanics and Locator Rules

For bounded, self-contained support work, use sap-task-helper with explicit inputs, allowed writes, and an output contract.

Non-negotiable execution gate

The abapfs_run_playwright_tests tool verifies the workflow artifacts produced from WebGUI exploration and will reject affected cases when required screen mappings or script checks are missing. Do not guess locators or skip live verification.

Related workflows

Apply the guidance below for WebGUI mechanics and pitfalls. When the task also requires another workflow:

Labels versus IDs

SAP WebGUI DOM IDs, generated reference numbers, row indexes, and CSS class suffixes can change across sessions, themes, support-package levels, and screen rerenders. Do not use them as test contracts.

Prefer, in order:

  1. semantic role + exact accessible name;
  2. role/name scoped to a verified dialog or group;
  3. stable title or aria-label for toolbar controls;
  4. visible cell text for grids;
  5. sap.setGridCell(columnTitle, rowIndex, value) for editable ALV cells whose inputs have no accessible name (see “Editable ALV grid cells” below);
  6. { technicalName: "<ABAP_FIELD>" } on sap.setField(...) when two visible fields share the same label — last-resort disambiguator via the SAP data-dictionary name inside lsdata (see “The lsdata attribute” below);
  7. a narrowly-contained sap.raw() locator using role/name when no helper fits.

The on-screen label and DOM accessible name are often—but not always—the same. Exploration must record both when they differ. English UI language is required because labels are part of the locator contract.

Interpreting Playwright recordings

Recordings are interaction evidence, not production specs. Classify generated code before using it:

Preferred evidence

Conditionally usable evidence

Unsafe recording output

Complex dynpro and ME21N patterns

Stable replacement decision

For every required recorded interaction:

  1. Use the matching SapSession helper with labels and scopes verified in _screens.md.
  2. If no helper fits, use one narrow sap.raw() role/name, title, aria-label, or stable visible-text locator confirmed by live evidence.
  3. If the recording exposes only an unsafe ID or coordinate, stop. Obtain focused exploration evidence or report a runtime/control-accessibility gap.

Never “improve” an unsafe ID by shortening it, regex-matching part of it, or replacing it with an unverified position.

WebGUI structure and common traps

SAP selection screens (SE38 / SUBMIT with SELECTION-SCREEN)

Selection screens — the initial parameter screen of every SAP report — behave differently from dynpro maintenance screens (ME21N/MIGO/VA01) and are the source of the two most common build-scripts mistranslations. Rules for the whole family:

Dynpro screens (ME21N/MIGO/VA01/…) DO expose real groups/regions in many places — { group: "..." } is legitimate there when _screens.md records it. The rule is: emit group when the map records it, omit otherwise; do not emit it reflexively.

Header tab strips

Dynpro screens like ME21N, MIGO, VA01, and every FI/CO document use a tab strip to switch between header sections (Delivery/Invoice, Conditions, Texts, Org. Data, …). ITS renders each tab as:

<div class="lsTbsItem--scrollable lsTbsv5-Item">
  <div class="lsTbsv5-ItemTitle">Org. Data</div>
  <div class="lsTbsv5-ItmWidthHelper">Org. Data</div>
  <!-- hidden duplicate for layout -->
</div>

Key mechanics:

The sap.clickTab(name) helper handles all of this: it tries role=tab first (Fiori), then falls back to matching the ItemTitle by exact text and DOM-clicking its closest lsTbsItem ancestor. Never open-code a tab click; never use clickButton on a tab (buttons and tabs have different DOM contracts even though both look clickable).

Live-exploration checklist for a tab strip: record every tab label EXACTLY as displayed (including punctuation like the period in "Org. Data" or the slash in "Delivery/Invoice"), the currently-selected tab on entry to the screen, and whether the tab strip is at the header or item-detail level (both exist on ME21N).

Editable grids — TWO different renderers, do not assume one

WebGUI renders editable tables with one of two different DOM schemes, and they are NOT interchangeable. Record which one a screen uses during exploration, because a locator built for one fails silently on the other:

  1. Dynpro table control (classic module-pool tables) — cell ids look like <prefix>[row,col] and the editor is <prefix>[row,col]_c; the column header <th> carries a title. This is the scheme detailed below.
  2. CL_GUI_ALV_GRID grid (the SAP control-framework ALV) — cell/column ids follow a different scheme (a grid container id with #-separated row/column parts, e.g. grid#…#r,c#…), the header often has NO title, and — critically — after you type a value the grid only moves it into its internal buffer on a change/blur/Enter event. A bare fill() sets the DOM value but the grid never reads it, so on commit the cell reverts and the "test" runs on empty data.

Always drive editable cells through sap.setGridCell(columnTitle, rowIndex, value), never a hand-rolled sap.raw() fill(). The helper detects the renderer, finds the column by its header text/title, clicks the cell to materialise the editor, fills, AND fires the commit the ALV grid needs. A raw fill() on a grid input is the specific mistake that produces green-on-empty results. If setGridCell cannot drive a particular grid, that is a runtime gap to report (helpers-reference) — not a cue to reach for raw().

The dynpro table-control scheme in detail:

Editable ALV/table cells only materialize an <input> after the user clicks or tabs into them. Structure:

<table id="tbl317">
  <!-- outer container, prefix changes per session -->
  <table id="tbl317-mrss-hdr-none-content">
    <!-- header row(s), scrollable columns -->
    <th id="tbl317[0,5]" title="Article">
      <!-- column header, title is stable -->
      <table id="tbl317-mrss-cont-none-content">
        <!-- data rows, scrollable columns -->
        <td id="tbl317[1,5]"><!-- row 1, col 5 --></td>
      </table>
    </th>
  </table>
</table>

After a real click on the <td>, SAP injects <input id="tbl317[1,5]_c"> inside it and focuses the input. The input has no accessible name and no title — sap.setField can't find it. The column title lives on the header <th>, not the cell input.

Key mechanics:

The sap.setGridCell(columnTitle, rowIndex, value) helper handles the whole flow: find header by title, derive tbl<N> prefix + column index, click the target row-cell, wait for the input to materialize, fill.

Live-exploration checklist for an editable grid: record WHICH renderer it is (dynpro table control vs CL_GUI_ALV_GRID — check a cell id in the snapshot: [r,c] vs a #-separated grid id); the column title/header text for every editable column the case touches (case-sensitive, matches the visible label); how many data rows are visible by default (grids often show 8–10); any personalized variant that changes column order; and whether all columns of interest are visible without horizontal scroll. (setGridCell handles both renderers — you record the renderer so Phase 6 knows the grid is ALV-type and never hand-rolls a fill().)

Read-only grids (SE16, ALV output of a report) usually work with sap.expectGridHasRow(text) or sap.selectGridRowByText(text) because their cells carry text content, not editable inputs.

The `lsdata` attribute

Every ITS input/control has an lsdata attribute whose value is a JSON blob:

<input
  title="Purchasing Organization"
  lsdata='{"1":"FREETEXT",...,"21":{"SID":"wnd[0]/usr/.../ctxtMEPO1222-EKORG","Type":"GuiCTextField",...}}'
/>

The SID string embeds the ABAP screen-element path, which ends with <control-type><TABLE>-<FIELD>. The trailing -<FIELD> piece is the SAP data-dictionary field name (EKORG, EBELN, LIFNR, WERKS, ...) and is stable across sessions, themes, and support packages because it comes from the DDIC, not from the DOM renderer.

When to use { technicalName: "<FIELD>" }:

When NOT to use it:

sap.setField(..., { technicalName: "..." }) uses the technical name whenever the accessible name is NOT a unique match — i.e. when it matches multiple fields (the duplicate-label case this is designed for) OR matches nothing. It never overrides a UNIQUE role+name match, so the helper stays role-first: a clean single label wins, but the moment a label is ambiguous the technical name takes over instead of silently filling the first match. If the label is ambiguous and no technicalName is supplied, setField throws and asks for one (or a verified nth) rather than guessing — so a from/to pair with identical labels can't silently collapse into one field.

Required live-exploration record

For every screen/dialog used by a case, record in _screens.md:

Never derive _screens.md from ABAP source alone.

Popup guard and auto-dismissed dialogs

SapSession runs dismissKnownPopups before and after every action. It only auto-clicks dialogs whose title matches a curated allow-list of "safe-to-dismiss" interrupters — anything else is left alone so real bugs surface as test failures.

Current allow-list of auto-dismissed dialogs:

Deliberately NOT on the list:

Match titles must be specific enough to avoid false positives.

Key behaviour:

Adding a program-specific interrupter: pass extraInterrupters to new SapSession(...). Example: a custom "Reprint output?" dialog on your Z-report can be auto-dismissed with { matchTitle: "Reprint output", dismissButton: "No", note: "..." }.

SAP runtime errors and short dumps

SapSession also runs detectRuntimeError after every action. This catches three failure modes that SAP does NOT expose as dialogs:

When detected, the guard captures evidence and throws with kind, title, URL, and a 500-char body snippet — never silently continue.

Silent transaction bounce — SAP sometimes doesn't produce ANY error and just drops the user back to SAP Easy Access (SAPMSYST/40 / S000) when a transaction doesn't exist in this client or the user lacks S_TCODE. sap.openTx(...) verifies the target loaded via detectSilentBounce and throws a specific S_TCODE/authorisation hint.

Explicit assertion: use sap.expectNoRuntimeError() at a point where dump-freedom is part of the test contract (e.g. after a long batch execution). Redundant most of the time — the guarded() path already checks — but useful for post-condition assertions.

Current helper reliability

The helper strategy—semantic role and accessible name first—is substantially more stable than generated WebGUI IDs. It is not universally reliable without live verification:

Therefore, use helpers by default, but treat _screens.md plus the first headed run as required proof for each new screen pattern. A helper failure is not permission to switch to generated IDs.

Locator failure patterns

Use these patterns during run-scripts diagnosis:

Correct the observed control in _screens.md (via explore-ui), then follow build-scripts to rebuild the spec. Do not patch the locator ad hoc during Phase 7 (run-scripts) diagnosis.

Before writing or approving a script

Confirm:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.