Skip to main content
Glama

CheckFunctionModule

Verify ABAP function module syntax and retrieve errors, warnings, and messages.

Instructions

Perform syntax check on an ABAP function module. Returns syntax errors, warnings, and messages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
function_group_nameYesFunction group name containing the function module.
function_module_nameYesFunction module name (e.g., Z_MY_FUNCTION).
versionNoVersion to check: 'active' or 'inactive'. Default: active.

Implementation Reference

  • High-level handler for CheckFunctionModule. Delegates to the low-level handler and normalizes the response (strips session fields, adds object_name).
    export async function handleCheckFunctionModule(
      context: HandlerContext,
      args: {
        function_group_name: string;
        function_module_name: string;
        version?: string;
      },
    ) {
      const result = await handleCheckFunctionModuleLow(context, args);
      return normalizeCheckResponse(
        result,
        args.function_module_name?.toUpperCase(),
      );
    }
  • Low-level handler for CheckFunctionModule. Uses ADT client to perform syntax check on an ABAP function module, parses the check run response, and returns detailed results including errors/warnings.
    export async function handleCheckFunctionModule(
      context: HandlerContext,
      args: CheckFunctionModuleArgs,
    ) {
      const { connection, logger } = context;
      try {
        const {
          function_group_name,
          function_module_name,
          version = 'active',
          session_id,
          session_state,
        } = args as CheckFunctionModuleArgs;
    
        if (!function_group_name || !function_module_name) {
          return return_error(
            new Error('function_group_name and function_module_name are required'),
          );
        }
    
        const checkVersion =
          version && ['active', 'inactive'].includes(version.toLowerCase())
            ? (version.toLowerCase() as 'active' | 'inactive')
            : 'active';
    
        // Restore session state if provided
        if (session_id && session_state) {
          await restoreSessionInConnection(connection, session_id, session_state);
        } else {
          // Ensure connection is established
        }
    
        const functionGroupName = function_group_name.toUpperCase();
        const functionModuleName = function_module_name.toUpperCase();
    
        logger?.info(
          `Starting function module check: ${functionModuleName} in group ${functionGroupName} (version: ${checkVersion})`,
        );
    
        try {
          const client = createAdtClient(connection, logger);
          const checkState = await client.getFunctionModule().check(
            {
              functionModuleName: functionModuleName,
              functionGroupName: functionGroupName,
            },
            checkVersion,
          );
          const response = checkState.checkResult;
          if (!response) {
            throw new Error('Function module check did not return a response');
          }
    
          // Parse check results
          const checkResult = parseCheckRunResponse(response as AxiosResponse);
    
          // Get updated session state after check
    
          logger?.info(`✅ CheckFunctionModule completed: ${functionModuleName}`);
          logger?.debug(
            `Status: ${checkResult.status} | Errors: ${checkResult.errors.length}, Warnings: ${checkResult.warnings.length}`,
          );
    
          return return_response({
            data: JSON.stringify(
              {
                success: checkResult.success,
                function_group_name: functionGroupName,
                function_module_name: functionModuleName,
                version: checkVersion,
                check_result: checkResult,
                session_id: session_id,
                session_state: null, // Session state management is now handled by auth-broker,
                message: checkResult.success
                  ? `Function module ${functionModuleName} has no syntax errors`
                  : `Function module ${functionModuleName} has ${checkResult.errors.length} error(s) and ${checkResult.warnings.length} warning(s)`,
              },
              null,
              2,
            ),
          } as AxiosResponse);
        } catch (error: any) {
          logger?.error(
            `Error checking function module ${functionModuleName}: ${error?.message || error}`,
          );
    
          let errorMessage = `Failed to check function module: ${error.message || String(error)}`;
    
          if (error.response?.status === 404) {
            errorMessage = `Function module ${functionModuleName} 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);
      }
    }
  • High-level tool definition (schema) for CheckFunctionModule with input schema requiring function_group_name and function_module_name, with optional version.
    export const TOOL_DEFINITION = {
      name: 'CheckFunctionModule',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        'Perform syntax check on an ABAP function module. Returns syntax errors, warnings, and messages.',
      inputSchema: {
        type: 'object',
        properties: {
          function_group_name: {
            type: 'string',
            description: 'Function group name containing the function module.',
          },
          function_module_name: {
            type: 'string',
            description: 'Function module name (e.g., Z_MY_FUNCTION).',
          },
          version: {
            type: 'string',
            description:
              "Version to check: 'active' or 'inactive'. Default: active.",
            enum: ['active', 'inactive'],
          },
        },
        required: ['function_group_name', 'function_module_name'],
      },
    } as const;
  • Low-level tool definition (schema) for CheckFunctionModuleLow, including additional session_id/session_state properties.
    export const TOOL_DEFINITION = {
      name: 'CheckFunctionModuleLow',
      available_in: ['onprem', 'cloud', 'legacy'] as const,
      description:
        '[low-level] Perform syntax check on an ABAP function module. Returns syntax errors, warnings, and messages. Requires function group name. Can use session_id and session_state from GetSession to maintain the same session.',
      inputSchema: {
        type: 'object',
        properties: {
          function_group_name: {
            type: 'string',
            description: 'Function group name (e.g., Z_FUGR_TEST_0001)',
          },
          function_module_name: {
            type: 'string',
            description: 'Function module name (e.g., Z_TEST_FM)',
          },
          version: {
            type: 'string',
            description:
              "Version to check: 'active' (last activated) or 'inactive' (current unsaved). Default: active",
            enum: ['active', 'inactive'],
          },
          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: ['function_group_name', 'function_module_name'],
      },
    } as const;
  • Import of CheckFunctionModule_Tool and handleCheckFunctionModule from the high-level handler.
    import {
      TOOL_DEFINITION as CheckFunctionModule_Tool,
      handleCheckFunctionModule,
    } from '../../../handlers/function/high/handleCheckFunctionModule';
  • Registration of CheckFunctionModule with its tool definition and handler in the HighLevelHandlersGroup map.
    {
      toolDefinition: CheckFunctionModule_Tool,
      handler: withContext(handleCheckFunctionModule),
    },
Behavior3/5

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

The description discloses that the tool returns syntax errors, warnings, and messages, which is the core behavior. However, it does not explicitly state that it is non-destructive, which would be helpful given the absence of annotations.

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 a single sentence that conveys the essential purpose and output. No wasted words, easy to parse quickly.

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 simple check tool with 3 parameters and no output schema, the description adequately covers what it does and what it returns. Minor missing context includes prerequisites like the function group existing, but overall it is sufficient.

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 input schema already describes all parameters. The description adds no additional meaning beyond what the schema provides, making it baseline.

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 action ('perform syntax check') and the resource ('ABAP function module'), which distinguishes it from sibling Check* tools that check other object types like classes or tables.

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?

While the description implies usage for checking function modules, it does not explicitly state when to use this tool versus other check tools, nor does it mention any prerequisites or exclusions.

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