Skip to main content
Glama

DeleteServiceDefinition

Delete an ABAP service definition from the SAP system after performing a deletion check. Optionally specify a transport request for $TMP objects.

Instructions

Delete an ABAP service definition from the SAP system. Includes deletion check before actual deletion. Transport request optional for $TMP objects.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
service_definition_nameYesServiceDefinition name (e.g., Z_MY_SERVICEDEFINITION).
transport_requestNoTransport request number (e.g., E19K905635). Required for transportable objects. Optional for local objects ($TMP).

Implementation Reference

  • Main handler function for DeleteServiceDefinition. Uses AdtClient.getServiceDefinition().delete() to delete an ABAP service definition. Includes validation, error handling with specific HTTP status codes (404, 423, 400), and XML parsing of SAP error responses.
    export async function handleDeleteServiceDefinition(
      context: HandlerContext,
      args: DeleteServiceDefinitionArgs,
    ) {
      const { connection, logger } = context;
      try {
        const { service_definition_name, transport_request } =
          args as DeleteServiceDefinitionArgs;
    
        // Validation
        if (!service_definition_name) {
          return return_error(new Error('service_definition_name is required'));
        }
    
        const client = createAdtClient(connection, logger);
        const serviceDefinitionName = service_definition_name.toUpperCase();
    
        logger?.info(
          `Starting service definition deletion: ${serviceDefinitionName}`,
        );
    
        try {
          // Delete service definition using AdtClient (includes deletion check)
          const serviceDefinitionObject = client.getServiceDefinition();
          const deleteResult = await serviceDefinitionObject.delete({
            serviceDefinitionName,
            transportRequest: transport_request,
          });
    
          if (!deleteResult || !deleteResult.deleteResult) {
            throw new Error(
              `Delete did not return a response for service definition ${serviceDefinitionName}`,
            );
          }
    
          logger?.info(
            `✅ DeleteServiceDefinition completed successfully: ${serviceDefinitionName}`,
          );
    
          return return_response({
            data: JSON.stringify(
              {
                success: true,
                service_definition_name: serviceDefinitionName,
                transport_request: transport_request || null,
                message: `ServiceDefinition ${serviceDefinitionName} deleted successfully.`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error deleting service definition ${serviceDefinitionName}: ${error?.message || error}`,
          );
    
          // Parse error message
          let errorMessage = `Failed to delete service definition: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `ServiceDefinition ${serviceDefinitionName} not found. It may already be deleted.`;
          } else if (error.response?.status === 423) {
            errorMessage = `ServiceDefinition ${serviceDefinitionName} is locked by another user. Cannot delete.`;
          } else if (error.response?.status === 400) {
            errorMessage = `Bad request. Check if transport request is required and valid.`;
          } 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 (inputSchema) for DeleteServiceDefinition. Defines name, availability (onprem/cloud), description, and input schema with required 'service_definition_name' string and optional 'transport_request' string.
    export const TOOL_DEFINITION = {
      name: 'DeleteServiceDefinition',
      available_in: ['onprem', 'cloud'] as const,
      description:
        'Delete an ABAP service definition from the SAP system. Includes deletion check before actual deletion. Transport request optional for $TMP objects.',
      inputSchema: {
        type: 'object',
        properties: {
          service_definition_name: {
            type: 'string',
            description: 'ServiceDefinition name (e.g., Z_MY_SERVICEDEFINITION).',
          },
          transport_request: {
            type: 'string',
            description:
              'Transport request number (e.g., E19K905635). Required for transportable objects. Optional for local objects ($TMP).',
          },
        },
        required: ['service_definition_name'],
      },
    } as const;
  • TypeScript interface DeleteServiceDefinitionArgs defining the shape of the args parameter with service_definition_name (required) and transport_request (optional).
    interface DeleteServiceDefinitionArgs {
      service_definition_name: string;
      transport_request?: string;
    }
  • Registration of DeleteServiceDefinition in HighLevelHandlersGroup. Imports TOOL_DEFINITION (aliased as DeleteServiceDefinition_Tool) and handleDeleteServiceDefinition handler, then registers them together as a handler entry with toolDefinition and handler wrapped with context.
    import {
      TOOL_DEFINITION as DeleteServiceDefinition_Tool,
      handleDeleteServiceDefinition,
    } from '../../../handlers/service_definition/high/handleDeleteServiceDefinition';
    import {
      TOOL_DEFINITION as GetServiceDefinition_Tool,
      handleGetServiceDefinition,
    } from '../../../handlers/service_definition/high/handleGetServiceDefinition';
    import {
      handleUpdateServiceDefinition,
      TOOL_DEFINITION as UpdateServiceDefinition_Tool,
    } from '../../../handlers/service_definition/high/handleUpdateServiceDefinition';
    import {
      TOOL_DEFINITION as ActivateServiceDefinition_Tool,
      handleActivateServiceDefinition,
    } from '../../../handlers/service_definition/low/handleActivateServiceDefinition';
    import {
      TOOL_DEFINITION as CheckStructure_Tool,
      handleCheckStructure,
    } from '../../../handlers/structure/high/handleCheckStructure';
    import {
      TOOL_DEFINITION as CreateStructure_Tool,
      handleCreateStructure,
    } from '../../../handlers/structure/high/handleCreateStructure';
    import {
      TOOL_DEFINITION as DeleteStructure_Tool,
      handleDeleteStructure,
    } from '../../../handlers/structure/high/handleDeleteStructure';
    import {
      TOOL_DEFINITION as GetStructure_Tool,
      handleGetStructure,
    } from '../../../handlers/structure/high/handleGetStructure';
    import {
      handleUpdateStructure as handleUpdateStructureHigh,
      TOOL_DEFINITION as UpdateStructureHigh_Tool,
    } from '../../../handlers/structure/high/handleUpdateStructure';
    import {
      TOOL_DEFINITION as ActivateStructure_Tool,
      handleActivateStructure,
    } from '../../../handlers/structure/low/handleActivateStructure';
    import {
      TOOL_DEFINITION as CheckTable_Tool,
      handleCheckTable,
    } from '../../../handlers/table/high/handleCheckTable';
    import {
      TOOL_DEFINITION as CreateTable_Tool,
      handleCreateTable,
    } from '../../../handlers/table/high/handleCreateTable';
    import {
      TOOL_DEFINITION as DeleteTable_Tool,
      handleDeleteTable,
    } from '../../../handlers/table/high/handleDeleteTable';
    import {
      TOOL_DEFINITION as GetTable_Tool,
      handleGetTable,
    } from '../../../handlers/table/high/handleGetTable';
    import {
      handleUpdateTable as handleUpdateTableHigh,
      TOOL_DEFINITION as UpdateTableHigh_Tool,
    } from '../../../handlers/table/high/handleUpdateTable';
    import {
      TOOL_DEFINITION as ActivateTable_Tool,
      handleActivateTable,
    } from '../../../handlers/table/low/handleActivateTable';
    import {
      TOOL_DEFINITION as CreateTransport_Tool,
      handleCreateTransport,
    } from '../../../handlers/transport/high/handleCreateTransport';
    import {
      TOOL_DEFINITION as CreateCdsUnitTest_Tool,
      handleCreateCdsUnitTest,
    } from '../../../handlers/unit_test/high/handleCreateCdsUnitTest';
    import {
      TOOL_DEFINITION as CreateUnitTest_Tool,
      handleCreateUnitTest,
    } from '../../../handlers/unit_test/high/handleCreateUnitTest';
    import {
      TOOL_DEFINITION as DeleteCdsUnitTest_Tool,
      handleDeleteCdsUnitTest,
    } from '../../../handlers/unit_test/high/handleDeleteCdsUnitTest';
    import {
      TOOL_DEFINITION as DeleteUnitTest_Tool,
      handleDeleteUnitTest,
    } from '../../../handlers/unit_test/high/handleDeleteUnitTest';
    import {
      TOOL_DEFINITION as GetCdsUnitTest_Tool,
      handleGetCdsUnitTest,
    } from '../../../handlers/unit_test/high/handleGetCdsUnitTest';
    import {
      TOOL_DEFINITION as GetCdsUnitTestResult_Tool,
      handleGetCdsUnitTestResult,
    } from '../../../handlers/unit_test/high/handleGetCdsUnitTestResult';
    import {
      TOOL_DEFINITION as GetCdsUnitTestStatus_Tool,
      handleGetCdsUnitTestStatus,
    } from '../../../handlers/unit_test/high/handleGetCdsUnitTestStatus';
    import {
      TOOL_DEFINITION as GetUnitTest_Tool,
      handleGetUnitTest,
    } from '../../../handlers/unit_test/high/handleGetUnitTest';
    import {
      TOOL_DEFINITION as GetUnitTestResult_Tool,
      handleGetUnitTestResult,
    } from '../../../handlers/unit_test/high/handleGetUnitTestResult';
    import {
      TOOL_DEFINITION as GetUnitTestStatus_Tool,
      handleGetUnitTestStatus,
    } from '../../../handlers/unit_test/high/handleGetUnitTestStatus';
    import {
      handleRunUnitTest,
      TOOL_DEFINITION as RunUnitTest_Tool,
    } from '../../../handlers/unit_test/high/handleRunUnitTest';
    import {
      handleUpdateCdsUnitTest,
      TOOL_DEFINITION as UpdateCdsUnitTest_Tool,
    } from '../../../handlers/unit_test/high/handleUpdateCdsUnitTest';
    import {
      handleUpdateUnitTest,
      TOOL_DEFINITION as UpdateUnitTest_Tool,
    } from '../../../handlers/unit_test/high/handleUpdateUnitTest';
    import {
      TOOL_DEFINITION as CheckView_Tool,
      handleCheckView,
    } from '../../../handlers/view/high/handleCheckView';
    import {
      TOOL_DEFINITION as CreateView_Tool,
      handleCreateView,
    } from '../../../handlers/view/high/handleCreateView';
    import {
      TOOL_DEFINITION as DeleteView_Tool,
      handleDeleteView,
    } from '../../../handlers/view/high/handleDeleteView';
    import {
      TOOL_DEFINITION as GetView_Tool,
      handleGetView,
    } from '../../../handlers/view/high/handleGetView';
    import {
      handleUpdateView as handleUpdateViewHigh,
      TOOL_DEFINITION as UpdateViewHigh_Tool,
    } from '../../../handlers/view/high/handleUpdateView';
    import {
      TOOL_DEFINITION as ActivateView_Tool,
      handleActivateView,
    } from '../../../handlers/view/low/handleActivateView';
    import { BaseHandlerGroup } from '../base/BaseHandlerGroup.js';
    import type { HandlerEntry } from '../interfaces.js';
    
    /**
     * Handler group for all high-level handlers
     * Contains handlers that perform CRUD operations using high-level APIs
     */
    export class HighLevelHandlersGroup extends BaseHandlerGroup {
      protected groupName = 'HighLevelHandlers';
    
      /**
       * Gets all high-level handler entries
       */
      getHandlers(): HandlerEntry[] {
        const withContext = <TArgs, TResult>(
          handler: (context: typeof this.context, args: TArgs) => TResult,
        ) => {
          return (args: unknown) => handler(this.context, args as TArgs);
        };
    
        return [
          // Common — group activation
          {
            toolDefinition: ActivateObjects_Tool,
            handler: withContext(handleActivateObjects),
          },
          // Per-type activation (reused from low-level, with high-level names/descriptions)
          {
            toolDefinition: {
              ...ActivateDomain_Tool,
              name: 'ActivateDomain',
              description:
                'Activate an ABAP domain. Use after CreateDomain or UpdateDomain if the object remains inactive.',
            },
            handler: withContext(handleActivateDomain),
          },
          {
            toolDefinition: {
              ...ActivateDataElement_Tool,
              name: 'ActivateDataElement',
              description:
                'Activate an ABAP data element. Use after CreateDataElement or UpdateDataElement if the object remains inactive.',
            },
            handler: withContext(handleActivateDataElement),
          },
          {
            toolDefinition: {
              ...ActivateTable_Tool,
              name: 'ActivateTable',
              description:
                'Activate an ABAP table. Use after CreateTable or UpdateTable if the object remains inactive.',
            },
            handler: withContext(handleActivateTable),
          },
          {
            toolDefinition: {
              ...ActivateStructure_Tool,
              name: 'ActivateStructure',
              description:
                'Activate an ABAP structure. Use after CreateStructure or UpdateStructure if the object remains inactive.',
            },
            handler: withContext(handleActivateStructure),
          },
          {
            toolDefinition: {
              ...ActivateView_Tool,
              name: 'ActivateView',
              description:
                'Activate a CDS view. Use after CreateView or UpdateView if the object remains inactive.',
            },
            handler: withContext(handleActivateView),
          },
          {
            toolDefinition: {
              ...ActivateClass_Tool,
              name: 'ActivateClass',
              description:
                'Activate an ABAP class. Use after CreateClass or UpdateClass if the object remains inactive.',
            },
            handler: withContext(handleActivateClass),
          },
          {
            toolDefinition: {
              ...ActivateInterface_Tool,
              name: 'ActivateInterface',
              description:
                'Activate an ABAP interface. Use after CreateInterface or UpdateInterface if the object remains inactive.',
            },
            handler: withContext(handleActivateInterface),
          },
          {
            toolDefinition: {
              ...ActivateProgram_Tool,
              name: 'ActivateProgram',
              description:
                'Activate an ABAP program. Use after CreateProgram or UpdateProgram if the object remains inactive.',
            },
            handler: withContext(handleActivateProgram),
          },
          {
            toolDefinition: {
              ...ActivateFunctionModule_Tool,
              name: 'ActivateFunctionModule',
              description:
                'Activate an ABAP function module. Use after UpdateFunctionModule if the object remains inactive.',
            },
            handler: withContext(handleActivateFunctionModule),
          },
          {
            toolDefinition: {
              ...ActivateFunctionGroup_Tool,
              name: 'ActivateFunctionGroup',
              description:
                'Activate an ABAP function group. Use after CreateFunctionGroup or UpdateFunctionGroup if the object remains inactive.',
            },
            handler: withContext(handleActivateFunctionGroup),
          },
          {
            toolDefinition: {
              ...ActivateBehaviorDefinition_Tool,
              name: 'ActivateBehaviorDefinition',
              description:
                'Activate a RAP behavior definition. Use after CreateBehaviorDefinition or UpdateBehaviorDefinition if the object remains inactive.',
            },
            handler: withContext(handleActivateBehaviorDefinition),
          },
          {
            toolDefinition: {
              ...ActivateMetadataExtension_Tool,
              name: 'ActivateMetadataExtension',
              description:
                'Activate a CDS metadata extension. Use after CreateMetadataExtension or UpdateMetadataExtension if the object remains inactive.',
            },
            handler: withContext(handleActivateMetadataExtension),
          },
          {
            toolDefinition: {
              ...ActivateServiceDefinition_Tool,
              name: 'ActivateServiceDefinition',
              description:
                'Activate an ABAP service definition. Use after CreateServiceDefinition or UpdateServiceDefinition if the object remains inactive.',
            },
            handler: withContext(handleActivateServiceDefinition),
          },
          {
            toolDefinition: {
              ...ActivateServiceBinding_Tool,
              name: 'ActivateServiceBinding',
              description:
                'Activate an ABAP service binding. Use after CreateServiceBinding or UpdateServiceBinding if the object remains inactive.',
            },
            handler: withContext(handleActivateServiceBinding),
          },
          {
            toolDefinition: CreatePackage_Tool,
            handler: withContext(handleCreatePackage),
          },
          {
            toolDefinition: GetPackage_Tool,
            handler: withContext(handleGetPackage),
          },
          {
            toolDefinition: CreateDomain_Tool,
            handler: withContext(handleCreateDomain),
          },
          {
            toolDefinition: GetDomain_Tool,
            handler: withContext(handleGetDomain),
          },
          {
            toolDefinition: UpdateDomainHigh_Tool,
            handler: withContext(handleUpdateDomainHigh),
          },
          {
            toolDefinition: DeleteDomain_Tool,
            handler: withContext(handleDeleteDomain),
          },
          {
            toolDefinition: CreateDataElement_Tool,
            handler: withContext(handleCreateDataElement),
          },
          {
            toolDefinition: GetDataElement_Tool,
            handler: withContext(handleGetDataElement),
          },
          {
            toolDefinition: UpdateDataElementHigh_Tool,
            handler: withContext(handleUpdateDataElementHigh),
          },
          {
            toolDefinition: DeleteDataElement_Tool,
            handler: withContext(handleDeleteDataElement),
          },
          {
            toolDefinition: CreateTransport_Tool,
            handler: withContext(handleCreateTransport),
          },
          {
            toolDefinition: CreateTable_Tool,
            handler: withContext(handleCreateTable),
          },
          {
            toolDefinition: GetTable_Tool,
            handler: withContext(handleGetTable),
          },
          {
            toolDefinition: UpdateTableHigh_Tool,
            handler: withContext(handleUpdateTableHigh),
          },
          {
            toolDefinition: DeleteTable_Tool,
            handler: withContext(handleDeleteTable),
          },
          {
            toolDefinition: CreateStructure_Tool,
            handler: withContext(handleCreateStructure),
          },
          {
            toolDefinition: GetStructure_Tool,
            handler: withContext(handleGetStructure),
          },
          {
            toolDefinition: UpdateStructureHigh_Tool,
            handler: withContext(handleUpdateStructureHigh),
          },
          {
            toolDefinition: DeleteStructure_Tool,
            handler: withContext(handleDeleteStructure),
          },
          {
            toolDefinition: CreateView_Tool,
            handler: withContext(handleCreateView),
          },
          {
            toolDefinition: GetView_Tool,
            handler: withContext(handleGetView),
          },
          {
            toolDefinition: UpdateViewHigh_Tool,
            handler: withContext(handleUpdateViewHigh),
          },
          {
            toolDefinition: DeleteView_Tool,
            handler: withContext(handleDeleteView),
          },
          {
            toolDefinition: CreateServiceDefinition_Tool,
            handler: withContext(handleCreateServiceDefinition),
          },
          {
            toolDefinition: GetServiceDefinition_Tool,
            handler: withContext(handleGetServiceDefinition),
          },
          {
            toolDefinition: UpdateServiceDefinition_Tool,
            handler: withContext(handleUpdateServiceDefinition),
          },
          {
            toolDefinition: DeleteServiceDefinition_Tool,
            handler: withContext(handleDeleteServiceDefinition),
          },
  • Registration in the compact router: SERVICE_DEFINITION object type maps the 'delete' CRUD operation to handleDeleteServiceDefinition.
    SERVICE_DEFINITION: {
      create: handleCreateServiceDefinition as unknown as CompactHandler,
      get: handleGetServiceDefinition as unknown as CompactHandler,
      update: handleUpdateServiceDefinition as unknown as CompactHandler,
      delete: handleDeleteServiceDefinition as unknown as CompactHandler,
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It notes a deletion check but does not disclose irreversibility, permissions, or side effects. More behavioral context is needed for a deletion tool.

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

Conciseness5/5

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

The description is concise with two sentences, front-loading the action and adding relevant detail without unnecessary fluff.

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

Completeness3/5

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

Given no annotations and no output schema, the description is somewhat incomplete. It does not explain the deletion check outcome, return values, or what happens after deletion, leaving gaps for the agent.

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?

Schema coverage is 100%, so the schema already documents parameters. The description echoes transport request optionality but adds no substantial new meaning beyond what the schema provides.

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 it deletes an ABAP service definition, using a specific verb and resource, and distinguishes it from sibling tools like DeleteBehaviorDefinition or DeleteClass.

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 implies usage through context but does not explicitly guide when to use this tool versus alternatives. It mentions transport request optionality but lacks when-to-use or when-not-to-use guidance.

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