Skip to content

Code Editing

stud0709 edited this page Jun 30, 2026 · 15 revisions

Code Editing Tools

This set of tools enables the agent to effectively edit and syntax-check ABAP sources. The editing workflow:

  • Fetch the file from SAP
  • Edit and check syntax in a local file
  • With write permission: push, activate. Without write permission: the user is responsible for pushing the source to SAP
  • Automated Shell Creation:
    • Dictionary Objects (DDIC): Pushing XML structures for Dictionary objects (Data Elements DTEL, Domains DOMA, Tables/Structures TABL, Table Types TTYP) via sap_push_source or sap_push_metadata automatically creates their backend shells upon encountering a 404 (not found) error.
    • Textual Repository Objects: Pushing plain-text source code via sap_push_source requires the object shell to exist on the backend first. However, the agent can create this shell automatically by pushing the object's XML metadata definition using the sap_push_metadata tool.
  • Every code push is recorded in the internal version control system.

Version Control

  • You can diff the versions and restore them to SAP system whenever needed.

Diff

Available MCP Tools

Tool Name Description
sap_activate_object Activates an inactive ABAP object (draft) in the SAP backend.
- Output: Automatically returns ABAP syntax errors via the chkl:messages payload if activation fails.
- Schema: Uses standard object_name and object_type (or object_uri) for URI resolution.
sap_ast_query Surgically locate structural node coordinates (Method, Form, Variable) using offline AST. Optionally provide object_uri to dynamically extract structural code segments remotely without loading massive payloads locally.
sap_ast_replace Structurally mutates the AST by cleanly replacing or deleting specific node constructs without regex strings.
sap_check_syntax Runs a native ADT syntax check matching Eclipse engine logic to validate ABAP code without saving.
sap_diff_versions Compares two source versions of an SAP object and returns a unified diff.
- Semantic Targets: "draft" (local file), "active" (live SAP active), "inactive" (live SAP inactive).
- Relative SQLite Targets: "-1" (latest local baseline), "-2" (version before that).
- Absolute SQLite Targets: "1", "2" (specific version numbers).
Defaults: from_version="draft", to_version="active".
sap_fetch_inactive_objects Fetches the list of all inactive objects currently held by the authenticated user from the SAP backend.
sap_fetch_metadata Retrieves the live XML metadata definition of any structural SAP object (e.g. Data Elements, Tables/Structures, Classes, Function Modules) directly from the ADT server. Staging option (for_editing: true) saves the XML to the local workspace for editing and baselines ETag tracking.
sap_get_creation_template Fetches a clean, patch-compatible XML creation template for a given SAP object type (DDIC or repository code objects), dynamically querying the backend or generating it offline.
sap_push_metadata Pushes modified local XML metadata back to the SAP backend. Handles locking, ETag staleness validation, transport request allocation, and automatic unlocking.
sap_push_source Pushes local ABAP source code (or XML representation) to the SAP backend as an inactive version.
- Auto-Unlocks: The object lock is automatically released upon success. Do not call sap_unlock_source.
- DDIC Creation: Automatically creates the backend shell for non-existent Dictionary objects on push.
- Errors: Fails with TRANSPORT_REQUIRED if a task number is missing.
- Orchestration: Consult .agents/skills/sap-dev/references/SOURCE_PUSH_GUIDE.md for template mutation and ETag collision recovery.
sap_scaffold_interface Orchestrates native AST-driven generation of a formatted implementation skeleton for any SAP Interface. Pings ADT's JSON logic engine offline. Provide the system_id, the source interface, and your destination definition.
sap_simulate_snippet Accepts a raw, un-wrapped block of ABAP code, dynamically injects it into Z_AGENT_SANDBOX, and executes ADT syntax validation cleanly.
sap_syntax_quick_fix Evaluates native SAP Syntax Quick Fixes for an offending source block.
- Evaluation: Pass object_uri, code, and finding_uri to evaluate available fixes.
- Extraction: Pass fix_index to retrieve the suggested replacement code snippet without mutating the backend.

Clone this wiki locally