Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
class_nameYesParent class name (e.g., ZCL_MY_CLASS).
transport_requestNoTransport request number.
activate_on_deleteNoActivate 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;
    }
  • 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';
  • 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),
    },
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses the tool manages lock, update, unlock, and optional activation. It also notes version support limitations. This provides behavioral context beyond a simple delete, though no annotations are present to contradict.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the action and steps. It is concise without being terse. The version note is relevant but could be separated for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a deletion tool with three parameters, the description covers purpose, steps, and a usage note. It lacks details on error handling or prerequisites, but is largely complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema coverage is 100%. The description does not add extra meaning beyond the schema, but the schema itself is clear. The default for activate_on_delete is conveyed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool deletes local macros from an ABAP class by clearing the macros include. It distinguishes from sibling tools like DeleteClass or UpdateLocalMacros.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description notes that macros are only supported in older ABAP versions, giving context for when the tool is applicable. However, it does not explicitly state when to use this tool versus alternatives like UpdateLocalMacros.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fr0ster/mcp-abap-adt'

If you have feedback or need assistance with the MCP directory API, please join our Discord server