ActivateInterface
Activate an ABAP interface after creation or update if the object remains inactive.
Instructions
Activate an ABAP interface. Use after CreateInterface or UpdateInterface if the object remains inactive.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| interface_name | Yes | Interface name (e.g., ZIF_MY_INTERFACE). | |
| session_id | No | Session ID from GetSession. If not provided, a new session will be created. | |
| session_state | No | Session state from GetSession (cookies, csrf_token, cookie_store). Required if session_id is provided. |
Implementation Reference
- Main handler function for the ActivateInterface tool. Uses AdtClient.activateInterface to activate an ABAP interface, parses the activation response, and returns status, messages, warnings, and errors.
export async function handleActivateInterface( context: HandlerContext, args: ActivateInterfaceArgs, ) { const { connection, logger } = context; try { const { interface_name, session_id, session_state } = args as ActivateInterfaceArgs; // Validation if (!interface_name) { return return_error(new Error('interface_name is required')); } const client = createAdtClient(connection, logger); // Restore session state if provided if (session_id && session_state) { await restoreSessionInConnection(connection, session_id, session_state); } const interfaceName = interface_name.toUpperCase(); logger?.info(`Starting interface activation: ${interfaceName}`); try { // Activate interface const activateState = await client .getInterface() .activate({ interfaceName: interfaceName }); const response = activateState.activateResult; if (!response) { throw new Error( `Activation did not return a response for interface ${interfaceName}`, ); } // Parse activation response const activationResult = parseActivationResponse(response.data); const success = activationResult.activated && activationResult.checked; // Get updated session state after activation logger?.info(`✅ ActivateInterface completed: ${interfaceName}`); logger?.debug( `Activated: ${activationResult.activated}, Checked: ${activationResult.checked}, Messages: ${activationResult.messages.length}`, ); return return_response({ data: JSON.stringify( { success, interface_name: interfaceName, activation: { activated: activationResult.activated, checked: activationResult.checked, generated: activationResult.generated, }, messages: activationResult.messages, warnings: activationResult.messages.filter( (m) => m.type === 'warning' || m.type === 'W', ), errors: activationResult.messages.filter( (m) => m.type === 'error' || m.type === 'E', ), session_id: session_id || null, session_state: null, // Session state management is now handled by auth-broker, message: success ? `Interface ${interfaceName} activated successfully` : `Interface ${interfaceName} activation completed with ${activationResult.messages.length} message(s)`, }, null, 2, ), } as AxiosResponse); } catch (error: any) { logger?.error( `Error activating interface ${interfaceName}: ${error?.message || error}`, ); // Parse error message let errorMessage = `Failed to activate interface: ${error.message || String(error)}`; if (error.response?.status === 404) { errorMessage = `Interface ${interfaceName} not found.`; } else if ( error.response?.data && typeof error.response.data === 'string' ) { try { const { XMLParser } = require('fast-xml-parser'); const parser = new XMLParser({ ignoreAttributes: false, attributeNamePrefix: '@_', }); const errorData = parser.parse(error.response.data); const errorMsg = errorData['exc:exception']?.message?.['#text'] || errorData['exc:exception']?.message; if (errorMsg) { errorMessage = `SAP Error: ${errorMsg}`; } } catch (_parseError) { // Ignore parse errors } } return return_error(new Error(errorMessage)); } } catch (error: any) { return return_error(error); } } - TOOL_DEFINITION constant with inputSchema for ActivateInterfaceLow. Requires interface_name, optional session_id and session_state.
export const TOOL_DEFINITION = { name: 'ActivateInterfaceLow', available_in: ['onprem', 'cloud', 'legacy'] as const, description: 'Operation: Activate, Create, Update. Subject: Interface. Will be useful for activating, creating, or updating interface. [low-level] Activate an ABAP interface. Returns activation status and any warnings/errors. Can use session_id and session_state from GetSession to maintain the same session.', inputSchema: { type: 'object', properties: { interface_name: { type: 'string', description: 'Interface name (e.g., ZIF_MY_INTERFACE).', }, session_id: { type: 'string', description: 'Session ID from GetSession. If not provided, a new session will be created.', }, session_state: { type: 'object', description: 'Session state from GetSession (cookies, csrf_token, cookie_store). Required if session_id is provided.', properties: { cookies: { type: 'string' }, csrf_token: { type: 'string' }, cookie_store: { type: 'object' }, }, }, }, required: ['interface_name'], }, } as const; - ActivateInterfaceArgs TypeScript interface defining the arguments shape for the handler.
interface ActivateInterfaceArgs { interface_name: string; session_id?: string; session_state?: { cookies?: string; csrf_token?: string; cookie_store?: Record<string, string>; }; } - src/lib/handlers/groups/HighLevelHandlersGroup.ts:557-565 (registration)Registration of ActivateInterface tool in HighLevelHandlersGroup. Uses the low-level TOOL_DEFINITION but overrides name to 'ActivateInterface' and provides a high-level description.
{ toolDefinition: { ...ActivateInterface_Tool, name: 'ActivateInterface', description: 'Activate an ABAP interface. Use after CreateInterface or UpdateInterface if the object remains inactive.', }, handler: withContext(handleActivateInterface), },