DeleteBehaviorImplementation
Delete an ABAP behavior implementation from the SAP system with a pre-deletion check. Supports optional transport request for local objects.
Instructions
Delete an ABAP behavior implementation from the SAP system. Includes deletion check before actual deletion. Transport request optional for $TMP objects.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| behavior_implementation_name | Yes | BehaviorImplementation name (e.g., Z_MY_BEHAVIORIMPLEMENTATION). | |
| transport_request | No | Transport request number (e.g., E19K905635). Required for transportable objects. Optional for local objects ($TMP). |
Implementation Reference
- Main handler function handleDeleteBehaviorImplementation - uses AdtClient.getBehaviorImplementation().delete() to delete an ABAP behavior implementation. Includes validation, deletion check, error handling with status codes (404, 423, 400), and SAP XML error parsing.
export async function handleDeleteBehaviorImplementation( context: HandlerContext, args: DeleteBehaviorImplementationArgs, ) { const { connection, logger } = context; try { const { behavior_implementation_name, transport_request } = args as DeleteBehaviorImplementationArgs; // Validation if (!behavior_implementation_name) { return return_error( new Error('behavior_implementation_name is required'), ); } const client = createAdtClient(connection, logger); const behaviorImplementationName = behavior_implementation_name.toUpperCase(); logger?.info( `Starting behavior implementation deletion: ${behaviorImplementationName}`, ); try { // Delete behavior implementation using AdtClient (includes deletion check) const behaviorImplementationObject = client.getBehaviorImplementation(); const deleteResult = await behaviorImplementationObject.delete({ className: behaviorImplementationName, transportRequest: transport_request, }); if (!deleteResult || !deleteResult.deleteResult) { throw new Error( `Delete did not return a response for behavior implementation ${behaviorImplementationName}`, ); } logger?.info( `✅ DeleteBehaviorImplementation completed successfully: ${behaviorImplementationName}`, ); return return_response({ data: JSON.stringify( { success: true, behavior_implementation_name: behaviorImplementationName, transport_request: transport_request || null, message: `BehaviorImplementation ${behaviorImplementationName} deleted successfully.`, }, null, 2, ), } as AxiosResponse); } catch (error: any) { logger?.error( `Error deleting behavior implementation ${behaviorImplementationName}: ${error?.message || error}`, ); // Parse error message let errorMessage = `Failed to delete behavior implementation: ${error.message || String(error)}`; if (error.response?.status === 404) { errorMessage = `BehaviorImplementation ${behaviorImplementationName} not found. It may already be deleted.`; } else if (error.response?.status === 423) { errorMessage = `BehaviorImplementation ${behaviorImplementationName} 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 export - schema for the DeleteBehaviorImplementation tool: name, availability (onprem/cloud), description, inputSchema requiring 'behavior_implementation_name' with optional 'transport_request'.
export const TOOL_DEFINITION = { name: 'DeleteBehaviorImplementation', available_in: ['onprem', 'cloud'] as const, description: 'Delete an ABAP behavior implementation from the SAP system. Includes deletion check before actual deletion. Transport request optional for $TMP objects.', inputSchema: { type: 'object', properties: { behavior_implementation_name: { type: 'string', description: 'BehaviorImplementation name (e.g., Z_MY_BEHAVIORIMPLEMENTATION).', }, transport_request: { type: 'string', description: 'Transport request number (e.g., E19K905635). Required for transportable objects. Optional for local objects ($TMP).', }, }, required: ['behavior_implementation_name'], }, } as const; - src/lib/handlers/groups/HighLevelHandlersGroup.ts:969-971 (registration)Tool registration in HighLevelHandlersGroup - maps DeleteBehaviorImplementation_Tool to handleDeleteBehaviorImplementation handler with context wrapping.
{ toolDefinition: DeleteBehaviorImplementation_Tool, handler: withContext(handleDeleteBehaviorImplementation), - src/handlers/compact/high/compactRouter.ts:220-225 (registration)Compact router registration for BEHAVIOR_IMPLEMENTATION object type with delete operation mapped to handleDeleteBehaviorImplementation.
BEHAVIOR_IMPLEMENTATION: { create: handleCreateBehaviorImplementation as unknown as CompactHandler, get: handleGetBehaviorImplementation as unknown as CompactHandler, update: handleUpdateBehaviorImplementation as unknown as CompactHandler, delete: handleDeleteBehaviorImplementation as unknown as CompactHandler, }, - DeleteBehaviorImplementationArgs TypeScript interface defining the input parameters: behavior_implementation_name (required) and transport_request (optional).
interface DeleteBehaviorImplementationArgs { behavior_implementation_name: string; transport_request?: string; }