DeleteLocalMacros
Remove local macros from ABAP classes by clearing the macros include, with automated lock handling and optional activation. Supports code migration from older to newer ABAP versions.
Instructions
Delete local macros from an ABAP class by clearing the macros include. Manages lock, update, unlock, and optional activation. Note: Macros are supported in older ABAP versions but not in newer ones.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| class_name | Yes | Parent class name (e.g., ZCL_MY_CLASS). | |
| transport_request | No | Transport request number. | |
| activate_on_delete | No | Activate parent class after deleting. Default: false |
Implementation Reference
- The main handler function `handleDeleteLocalMacros` that deletes local macros from an ABAP class. It creates an ADT client, deletes the macros include via `localMacros.delete()`, optionally activates the class, and returns a success response.
export async function handleDeleteLocalMacros( context: HandlerContext, args: DeleteLocalMacrosArgs, ) { const { connection, logger } = context; try { const { class_name, transport_request, activate_on_delete = false, } = args as DeleteLocalMacrosArgs; if (!class_name) { return return_error(new Error('class_name is required')); } const client = createAdtClient(connection, logger); const className = class_name.toUpperCase(); logger?.info(`Deleting local macros for ${className}`); try { const localMacros = client.getLocalMacros(); const deleteResult = await localMacros.delete({ className, transportRequest: transport_request, }); if (!deleteResult) { throw new Error(`Delete did not return a result for ${className}`); } if (activate_on_delete) { await client.getClass().activate({ className }); } logger?.info(`✅ DeleteLocalMacros completed successfully: ${className}`); return return_response({ data: JSON.stringify( { success: true, class_name: className, transport_request: transport_request || null, activated: activate_on_delete, message: `Local macros deleted successfully from ${className}.`, }, null, 2, ), } as AxiosResponse); } catch (error: any) { logger?.error( `Error deleting local macros for ${className}: ${error?.message || error}`, ); let errorMessage = `Failed to delete local macros: ${error.message || String(error)}`; if (error.response?.status === 404) { errorMessage = `Local macros for ${className} not found.`; } else if (error.response?.status === 423) { errorMessage = `Class ${className} is locked by another user.`; } return return_error(new Error(errorMessage)); } } catch (error: any) { return return_error(error); } } - The `TOOL_DEFINITION` object that defines the tool's name ('DeleteLocalMacros'), availability, description, and input schema (class_name required, transport_request optional, activate_on_delete optional boolean).
export const TOOL_DEFINITION = { name: 'DeleteLocalMacros', available_in: ['onprem', 'cloud', 'legacy'] as const, description: 'Delete local macros from an ABAP class by clearing the macros include. Manages lock, update, unlock, and optional activation. Note: Macros are supported in older ABAP versions but not in newer ones.', inputSchema: { type: 'object', properties: { class_name: { type: 'string', description: 'Parent class name (e.g., ZCL_MY_CLASS).', }, transport_request: { type: 'string', description: 'Transport request number.', }, activate_on_delete: { type: 'boolean', description: 'Activate parent class after deleting. Default: false', default: false, }, }, required: ['class_name'], }, } as const; - The `DeleteLocalMacrosArgs` TypeScript interface defining the shape of the arguments passed to the handler.
interface DeleteLocalMacrosArgs { class_name: string; transport_request?: string; activate_on_delete?: boolean; } - src/lib/handlers/groups/HighLevelHandlersGroup.ts:54-61 (registration)Import of `DeleteLocalMacros_Tool` (aliased TOOL_DEFINITION) and `handleDeleteLocalMacros` from the handler file into the high-level handlers group registry.
import { TOOL_DEFINITION as DeleteLocalDefinitions_Tool, handleDeleteLocalDefinitions, } from '../../../handlers/class/high/handleDeleteLocalDefinitions'; import { TOOL_DEFINITION as DeleteLocalMacros_Tool, handleDeleteLocalMacros, } from '../../../handlers/class/high/handleDeleteLocalMacros'; - src/lib/handlers/groups/HighLevelHandlersGroup.ts:873-876 (registration)Registration of the DeleteLocalMacros tool in the high-level handlers group, pairing its tool definition with the `withContext(handleDeleteLocalMacros)` handler.
{ toolDefinition: DeleteLocalMacros_Tool, handler: withContext(handleDeleteLocalMacros), },