fetch_st22_dumps
Retrieve ABAP runtime error dumps (ST22) for a specified date, including dump time, user, error type, and program, by querying the SNAP table.
Instructions
Fetch ABAP runtime error dumps (ST22/short dumps) for a specific date. Returns dump time, user, runtime error type, and program. Queries the SNAP table and parses the encoded dump headers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | Date in YYYYMMDD or YYYY-MM-DD format (e.g. 20260402) | |
| user | No | Filter by SAP username (e.g. WF-BATCH) | |
| max_results | No | Max dumps to return (default: 100) | |
| system_id | No | SAP system ID (e.g. DEV). Omit to use default system. |
Implementation Reference
- src/mcp-server.ts:1527-1543 (handler)The handler for the fetch_st22_dumps tool. Parses input with FetchSt22Schema, builds an SQL query against the SNAP table, executes it via client.executeFreestyleSql(), parses the XML result with parseSnapDumps(), and formats output with formatSt22Dumps().
case "fetch_st22_dumps": { const parsed = FetchSt22Schema.parse(args); const dateStr = parsed.date.replace(/-/g, ""); const maxRows = parsed.max_results ?? 100; let query = `SELECT * FROM snap UP TO ${maxRows} ROWS WHERE datum = '${dateStr}' AND seqno = '000'`; if (parsed.user) { query += ` AND uname = '${parsed.user.toUpperCase()}'`; } query += ` ORDER BY uzeit DESCENDING`; const xml = await client.executeFreestyleSql(query); const dumps = parseSnapDumps(xml); const displayDate = `${dateStr.substring(0, 4)}-${dateStr.substring(4, 6)}-${dateStr.substring(6, 8)}`; const text = formatSt22Dumps(dumps, displayDate); return { content: [{ type: "text", text }] }; } - src/mcp-server.ts:117-121 (schema)Zod schema for fetch_st22_dumps input: date (required), user (optional), max_results (optional, default 100).
const FetchSt22Schema = z.object({ date: z.string().describe("Date in YYYYMMDD or YYYY-MM-DD format"), user: z.string().optional().describe("Filter by SAP username"), max_results: z.number().optional().describe("Max dumps to return (default: 100)"), }); - src/mcp-server.ts:952-967 (registration)Registration of fetch_st22_dumps in the ListTools handler. Defines the tool name, description, and input schema properties.
name: "fetch_st22_dumps", description: "Fetch ABAP runtime error dumps (ST22/short dumps) for a specific date. " + "Returns dump time, user, runtime error type, and program. " + "Queries the SNAP table and parses the encoded dump headers.", inputSchema: { type: "object" as const, properties: { date: { type: "string", description: "Date in YYYYMMDD or YYYY-MM-DD format (e.g. 20260402)" }, user: { type: "string", description: "Filter by SAP username (e.g. WF-BATCH)" }, max_results: { type: "number", description: "Max dumps to return (default: 100)", default: 100 }, ...SYSTEM_ID_PROP, }, required: ["date"], }, }, - src/snap-parser.ts:100-134 (helper)formatSt22Dumps() helper - formats the parsed ST22 dump data into a human-readable table. Called by the fetch_st22_dumps handler.
export function formatSt22Dumps(dumps: St22Dump[], date: string): string { if (dumps.length === 0) { return `No ST22 dumps found for ${date}`; } const totalRows = extractTotalRows(""); const header = `Found ${dumps.length} ST22 dump(s) on ${date}\n`; const padRight = (s: string, w: number) => s.length > w ? s.substring(0, w - 1) + "~" : s.padEnd(w); const cols = [ { label: "#", width: 4 }, { label: "Time", width: 8 }, { label: "User", width: 12 }, { label: "Runtime Error", width: 32 }, { label: "Program", width: 40 }, ]; const headerLine = cols.map((c) => padRight(c.label, c.width)).join(" | "); const separator = cols.map((c) => "-".repeat(c.width)).join("-+-"); const rows = dumps.map((d, i) => { const values = [ String(i + 1), formatTime(d.time), d.user, d.runtimeError, d.program, ]; return values.map((v, j) => padRight(v, cols[j].width)).join(" | "); }); return [header, headerLine, separator, ...rows].join("\n"); } - src/snap-parser.ts:73-98 (helper)parseSnapDumps() helper - parses XML data preview response (from SNAP table) into St22Dump objects. Used by the fetch_st22_dumps handler.
export function parseSnapDumps(xml: string): St22Dump[] { const columns = extractColumns(xml); if (columns.length === 0) return []; const colMap = new Map(columns.map((c) => [c.name, c.values])); const datumVals = colMap.get("DATUM") ?? []; const uzeitVals = colMap.get("UZEIT") ?? []; const unameVals = colMap.get("UNAME") ?? []; const ahostVals = colMap.get("AHOST") ?? []; const flistVals = colMap.get("FLIST") ?? []; const dumps: St22Dump[] = []; for (let i = 0; i < datumVals.length; i++) { const { runtimeError, program } = parseFlistField(flistVals[i] ?? ""); dumps.push({ date: datumVals[i] ?? "", time: uzeitVals[i] ?? "", user: (unameVals[i] ?? "").trim(), host: (ahostVals[i] ?? "").trim(), runtimeError, program, }); } return dumps; }