Skip to content

Debugging

stud0709 edited this page Oct 12, 2026 · 12 revisions

Debugging Tools & Workflows

The sap-dev AI skill provides comprehensive ABAP debugging capabilities built on the native SAP ADT HTTP debugger engine (/sap/bc/adt/debugger/*).

It supports debugging across SAP GUI for Windows, SAP GUI for Java, HTTP / OData / Fiori APIs, RFC Function Modules, and Background Tasks.


Available MCP Tools

Tool Name Lifecycle Stage Description
sap_debug_trace Recommended: One-shot debug trace. Sets a breakpoint, fires an asynchronous HTTP trigger, steps, evaluates SY & variables, and auto-detaches cleanly in a single call.
sap_debug_breakpoint Sets, lists, or clears this connection's owned project breakpoints.
sap_debug_attach Attaches to this debugger project's controlled HTTP trigger. Provide trigger_uri; use the connection user.
sap_debug_context Retrieves current call stack, local variables, and system fields for an active debug session.
sap_debug_step Executes single-step debugging commands (step into, step over, step return, or continue) in an active session.
sap_debug_evaluate Evaluates ABAP expressions, variables, or internal tables in an active debug session.
sap_debug_cleanup Terminates active SAP debugging sessions and deletes external breakpoints to prevent lock contention.

🚀 Debugging Tracks

Track A: One-Shot Request Trace (sap_debug_trace) [RECOMMENDED]

For 95% of API, OData, or backend debugging needs, use sap_debug_trace. It executes the entire lifecycle (set breakpoint $\rightarrow$ fire request $\rightarrow$ catch session $\rightarrow$ step $\rightarrow$ evaluate variables $\rightarrow$ auto-detach $\rightarrow$ wipe breakpoints) in a single tool call:

{
  "line": {
    "class": "CL_ADT_MESSAGE_CLASS_API",
    "line": 225
  },
  "trigger_request": {
    "uri": "/sap/bc/adt/messageclass?corrNr=A4HK900151",
    "method": "POST",
    "body": "<?xml version=\"1.0\"...?>"
  },
  "watch_variables": ["LV_SUBRC", "LV_OBJECT_NAME"],
  "auto_step_count": 2
}

Track B: Interactive API & RFC Stepping

When deep multi-step exploration or variable drilling is required:

  1. Set Breakpoint:
    sap_debug_breakpoint(action: "set", line: {class: "CL_MY_CLASS", line: 42})
  2. Attach Listener:
    sap_debug_attach(trigger_uri: "/sap/opu/odata/sap/ZSERVICE_SRV/EntitySet", timeout_seconds: 30)
  3. Step & Inspect:
    • sap_debug_step(action: "stepOver")
    • sap_debug_evaluate(parent_id: "LT_CUSTOMERS")
  4. Cleanup:
    • sap_debug_cleanup()

Track C: Agent-Assisted SAP GUI Debugging (Windows & Java GUI)

When debugging interactive transactions, classic Dynpro screens, or reports executed in SAP GUI for Windows or SAP GUI for Java:

sequenceDiagram
    autonumber
    actor User as Developer (SAP GUI)
    participant Bridge as sap-bridge (MCP)
    participant SAP as SAP Backend (Kernel)

    Note over User,SAP: One-Time Setup: Enable External Debugging in SE38 Settings
    Bridge->>SAP: sap_debug_breakpoint(set line 12 for User)
    Bridge->>SAP: sap_debug_attach(starts long-poll listener)
    User->>SAP: Enter /H_REFRESH_EXT_BPS in GUI command field
    SAP-->>User: "External breakpoints loaded, debugging activated"
    User->>SAP: Press F8 (Execute ZREPORT)
    SAP->>SAP: Work Process halts at Line 12
    SAP->>Bridge: Notify debuggee session
    Bridge->>SAP: Attach and fetch stack + variables
    Bridge-->>User: Returns variable inspection to AI Agent
    Bridge->>SAP: sap_debug_step(stepOver / detachDebugger)
    SAP-->>User: Resumes execution in SAP GUI window
Loading

1. One-Time SAP GUI Configuration

  1. Open transaction SE38 or SE80.
  2. Navigate to menu: Utilities $\rightarrow$ Settings $\rightarrow$ ABAP Editor $\rightarrow$ Debugging.
  3. Under Debug External Requests (e.g. RFC, HTTP):
    • Select the User radio button and verify your SAP username (e.g., YDZHENYEYEV).
    • Keep Current application server only unchecked.
  4. Click the green checkmark ($\checkmark$) to save.

2. Synchronize External Breakpoints in SAP GUI

Whenever new breakpoints are registered, load them into your active GUI session:

  • In the SAP GUI command box (top-left), enter:
    /H_REFRESH_EXT_BPS
    
    and press Enter. The status bar confirms: "External breakpoints loaded, debugging activated".
  • To explicitly re-bind your user session: /H_REACTIVATE_EXTD_DBG KIND=USER USER=<SY-UNAME>.

3. Automated Workflow (Agent-Driven)

The agent can automate the entire listen $\rightarrow$ resynchronize $\rightarrow$ execute sequence in one call:

sap_debug_attach(
  system_alias: "TD1-100",
  trigger_program: "ZPUZZLE_1X",
  timeout_seconds: 60
)

sap-bridge will establish the listener, trigger GUI resynchronization in the attached session, and run SE38 $\rightarrow$ F8.

4. Interactive Human-Assisted Workflow

When executing transactions or clicking buttons manually:

  1. Agent sets breakpoint: sap_debug_breakpoint(action: "set", line: {program: "ZREPORT", line: 12})
  2. Agent starts listener: sap_debug_attach(timeout_seconds: 120)
  3. Developer runs GUI action: In SAP GUI, run /H_REFRESH_EXT_BPS and press F8 (or click a dynpro button).
  4. Agent inspects: Work process halts; the agent receives current line, stack trace, and variable values.
  5. Agent steps or resumes:
    • sap_debug_step(action: "stepOver")
    • sap_debug_step(action: "detachDebugger") releases control back to your SAP GUI window.
  6. Cleanup: sap_debug_cleanup() ensures zero lingering backend locks.

Clone this wiki locally