get_abap_program
Retrieve the complete source code of any ABAP program or report from your SAP system by providing the program name. Optionally specify the system ID for multi-system environments.
Instructions
Fetch ABAP program/report source code from SAP system
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Program name (e.g. ZHANZ_CMR) | |
| system_id | No | SAP system ID (e.g. DEV). Omit to use default system. |
Implementation Reference
- src/mcp-server.ts:986-992 (handler)Handler for 'get_abap_program' tool. Parses the 'name' argument via NameSchema, then calls client.getSource() with the ADT URI for program source code and returns the result as text.
case "get_abap_program": { const { name: progName } = NameSchema.parse(args); const source = await client.getSource( `/sap/bc/adt/programs/programs/${encodeURIComponent(progName.toUpperCase())}/source/main` ); return { content: [{ type: "text", text: source }] }; } - src/mcp-server.ts:13-13 (schema)The NameSchema used for input validation: expects a single 'name' string field.
const NameSchema = z.object({ name: z.string() }); - src/mcp-server.ts:192-199 (registration)Registration of the 'get_abap_program' tool in the ListTools handler. Defines name, description, and inputSchema with required 'name' property and optional 'system_id'.
name: "get_abap_program", description: "Fetch ABAP program/report source code from SAP system", inputSchema: { type: "object" as const, properties: { name: { type: "string", description: "Program name (e.g. ZHANZ_CMR)" }, ...SYSTEM_ID_PROP }, required: ["name"], }, }, - src/adt-client.ts:56-62 (helper)The getSource() method in AdtClient used by the handler to fetch source code from the SAP system via a plain text GET request to the given ADT URI.
async getSource(path: string): Promise<string> { const response = await this.http.get<string>(path, { headers: { Accept: "text/plain" }, responseType: "text", }); return response.data; }