GetAdtTypes
Retrieve all valid ADT object types or validate a specific type name to ensure correct usage in ABAP development.
Instructions
[read-only] Retrieve all valid ADT object types (CLAS, TABL, PROG, DEVC, FUGR, INTF, DDLS, DTEL, DOMA, SRVD, SRVB, BDEF, DDLX, etc.) or validate a specific type name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| validate_type | No | Type name to validate (optional) |
Implementation Reference
- Main handler function for the GetAdtTypes tool. Creates an ADT client, fetches all object types from the SAP system via getAllTypes(), parses the XML response using extractNamedItems(), and returns the list of type names and descriptions as JSON content.
export async function handleGetAdtTypes(context: HandlerContext, _args: any) { const { connection, logger } = context; try { const client = createAdtClient(connection, logger); const response = await client .getUtils() .getAllTypes(999, '*', 'usedByProvider'); logger?.info('Fetched ADT object types list'); const items = extractNamedItems(response.data); return { isError: false, content: [ { type: 'text', text: JSON.stringify(items), }, ], }; } catch (error) { logger?.error('Failed to fetch ADT object types', error as any); return { isError: true, content: [ { type: 'text', text: `ADT error: ${String(error)}`, }, ], }; } } - Tool definition/input schema for GetAdtTypes. Defines the tool name, description, and optional 'validate_type' input property. Available in both onprem and cloud environments.
export const TOOL_DEFINITION = { name: 'GetAdtTypes', available_in: ['onprem', 'cloud'] as const, description: '[read-only] Retrieve all valid ADT object types (CLAS, TABL, PROG, DEVC, FUGR, INTF, DDLS, DTEL, DOMA, SRVD, SRVB, BDEF, DDLX, etc.) or validate a specific type name.', inputSchema: { type: 'object', properties: { validate_type: { type: 'string', description: 'Type name to validate (optional)', }, }, required: [], }, } as const; - src/lib/handlers/groups/SystemHandlersGroup.ts:220-226 (registration)Registration of GetAdtTypes in SystemHandlersGroup. Maps the toolDefinition (GetAdtTypes_Tool) to the handler (handleGetAdtTypes) with argument type casting.
// Dynamic import handlers { toolDefinition: GetAdtTypes_Tool, handler: (args: any) => { return handleGetAdtTypes(this.context, args as { type_name: string }); }, }, - Helper function extractNamedItems() that parses XML response from the nameditem:namedItemList structure to extract name/description pairs for ADT object types.
function extractNamedItems(xml: string) { const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '', parseAttributeValue: true, trimValues: true, }); const result = parser.parse(xml); const items: Array<{ name: string; description: string }> = []; const namedItems = result['nameditem:namedItemList']?.['nameditem:namedItem']; if (Array.isArray(namedItems)) { for (const item of namedItems) { items.push({ name: item['nameditem:name'], description: item['nameditem:description'], }); } } else if (namedItems) { items.push({ name: namedItems['nameditem:name'], description: namedItems['nameditem:description'], }); } return items; } - Helper function _parseObjectTypesXml() that parses XML for ADT object types from the opr:objectTypes structure. Defined but not used by the main handler (the extractNamedItems function is used instead).
function _parseObjectTypesXml(xml: string) { const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '', parseAttributeValue: true, trimValues: true, }); const result = parser.parse(xml); const types: { name: string; description: string; provider: string }[] = []; const objects = result['opr:objectTypes']?.['opr:objectType']; if (Array.isArray(objects)) { for (const obj of objects) { types.push({ name: obj.name, description: obj.text, provider: obj.provider, }); } } else if (objects) { types.push({ name: objects.name, description: objects.text, provider: objects.provider, }); } return types; }