# Set up for Unit 9: ABAP development tools and a coding agent

> Create a free SAP BTP ABAP trial system, connect Eclipse and VS Code to it, and let a coding agent use SAP's ADT MCP server with your approval.

- Course: Orchestrate, Unit 9 · AI-assisted SAP engineering
- Page: https://erpfde.com/topics/set-up-for-unit-09/
- Updated: 2026-10-09
- Reading time: Foundational 8 min, Deep 40 min

Independent learning resource. Not affiliated with, sponsored by or endorsed by SAP SE. SAP and other SAP products mentioned are trademarks of SAP SE in Germany and other countries.

## Foundational layer

### The 60-second version

Unit 9 is about AI that helps people build inside SAP. Until now, the course wrote Python next to SAP. This unit writes **ABAP**, SAP's own programming language, and lets an AI coding agent help.

This setup gives each learner three things:

- **A free ABAP system to practise on.** SAP offers an ABAP trial inside the SAP BTP trial you created in Unit 18.
- **SAP's development tools.** ABAP Development Tools, called **ADT**, in two editors: Eclipse, the long-standing one, and Visual Studio Code, which SAP added in 2026.
- **A coding agent wired to SAP.** The VS Code tools include an **ADT MCP server**. It lets an AI agent such as GitHub Copilot create and activate ABAP objects, but only when the learner allows each step.

Setup takes 60 to 90 minutes and costs nothing for a learner. The agent works on a shared practice system, never on company code.

### Why it matters to the business

Most SAP landscapes carry years of custom ABAP. Every upgrade, every clean-core project and every new extension needs developers who can read and change it. AI coding agents promise to speed that work up. They also bring a new risk: software that writes into an SAP system.

Take the running example. A team wants a small service that lists **blocked sales orders** for the credit team. A coding agent can draft the data model, the service and the tests in minutes. A developer still decides what goes in, checks the code, and owns the change.

Three things decide whether this pays off:

- **Where the agent can write.** A sandbox is fine. A development system with a transport route to production needs rules.
- **Who approves each change.** The agent should propose; a person should accept.
- **What it costs.** SAP's own ABAP AI features are licensed. Third-party agents have their own subscriptions.

This unit lets your team try the pattern safely before anyone debates it for a real system.

### How SAP does it

As of October 2026, SAP offers these pieces. Names and scope change often, so check before you plan around them.

- **ADT in Eclipse.** SAP's established ABAP editor, installed into the free Eclipse platform.
- **ADT for Visual Studio Code.** SAP News says ABAP development is possible in VS Code from Q2 2026. It started with ABAP Cloud, the clean-core development model, and SAP plans to add more object types through the year. SAP's tutorial lists three kinds of system it connects to: SAP BTP ABAP environment, SAP S/4HANA Cloud ABAP environment, and SAP S/4HANA 2025 or higher.
- **ABAP MCP server.** MCP, the Model Context Protocol, is the open standard from [Unit 8](https://erpfde.com/topics/model-context-protocol/) that lets agents use tools. SAP News describes ABAP MCP servers in Eclipse and VS Code as generally available in Q2 2026, and names GitHub Copilot and Amazon Q as agents that can use them. SAP's own workshop material still calls the VS Code server experimental, so treat it as new.
- **Joule for developers, ABAP AI capabilities.** SAP's own AI assistant for ABAP is a separate, licensed product. SAP News says SAP is moving its AI billing to usage-based **AI units**. This course doesn't assume you have it.
- **The ABAP trial.** A free, shared ABAP system in the SAP BTP trial, for learning only.

### What this unit adds

| Item | What it is | Cost | Used in |
| --- | --- | --- | --- |
| ABAP trial system | A shared practice ABAP system in your BTP trial | Free, time-limited | Every Unit 9 topic |
| Eclipse with ADT | SAP's long-standing ABAP editor | Free to download | Running ABAP classes, editors VS Code doesn't have yet |
| ADT for VS Code | SAP's ABAP tools for the editor you already use | Free to install | Every Unit 9 topic |
| ADT MCP server | Built into ADT for VS Code; gives agents ABAP tools | Included | Coding agents, the RAP service agent |
| GitHub Copilot Free | A coding agent inside VS Code | Free, with monthly limits | Coding agents for SAP developers |
| `check_unit09.py` | Proves the pieces work together | Free | Before every Unit 9 topic |

Unit 9 adds no Python libraries. The unit's last topic, where your own agent calls an ABAP service, adds its own.

### Time and money

- **Time:** 60 to 90 minutes. Eclipse and the trial booster take the longest.
- **Money for a learner:** nothing. The BTP trial, Eclipse, both sets of ADT and Copilot Free cost nothing. Copilot Free limits how much you can chat with the agent each month; the setup and the unit's exercises are small.
- **Trial clock:** SAP's help says the BTP trial from Unit 18 lasts 90 days and is suspended after 30 days without a sign-in. The ABAP trial lives inside it, and SAP community posts say its own period can be shorter, so check the end date in your trial cockpit.
- **Money for a company:** developer tools are free; systems and AI are not. Real work needs a licensed ABAP system, and AI help means either SAP's Joule for developers or a third-party agent subscription, or both.

### Questions to ask

Ask IT before you install:

- May we install Eclipse and VS Code extensions on company laptops, and from which sources?
- Which AI coding agents are approved, and are their chat logs kept by the vendor?
- Do company policies allow a personal GitHub account and Copilot Free for training, or must we use a company plan?
- Will our network allow the SAP BTP trial and the ABAP system's sign-in page?

Ask a partner who proposes AI-assisted ABAP development:

- Which systems will the agent be allowed to write to, and who approves each change?
- How will agent-made changes be reviewed and transported, the same as human changes?
- Which agent and model will see our custom code, and where does that code go?
- Is this based on SAP's Joule for developers, a third-party agent, or both? What does each cost?

### Common misconceptions

- **"The agent writes ABAP, so we need fewer reviews."** Agent-made code needs the same review, tests and transport discipline as any other change, often more.
- **"The trial is our sandbox."** The ABAP trial is shared with other learners and is for education only. Never put company code or data in it.
- **"ADT for VS Code replaces Eclipse today."** SAP started with ABAP Cloud and is adding object types through 2026. Many teams will use both for a while.
- **"MCP means the agent has its own SAP access."** The ADT MCP server works through the developer's own connection. The agent can do what that developer can do, which is why approvals matter.
- **"Copilot Free is the same as SAP's ABAP AI."** They are different products from different vendors, with different terms.

### Key terms

- **ABAP:** SAP's programming language for business applications.
- **ABAP Cloud:** SAP's clean-core way to write ABAP, using only released APIs.
- **ADT (ABAP Development Tools):** SAP's tools for writing ABAP in Eclipse or VS Code.
- **SAP BTP ABAP environment:** an ABAP system that SAP runs in the cloud on SAP BTP.
- **Coding agent:** an AI assistant that can read and change code and call tools, not just suggest text.
- **MCP server:** a program that offers tools to AI agents through the Model Context Protocol.
- **Transport request:** SAP's container for moving a change from one system to the next.

### Check yourself

1. What is the main purpose of this unit's setup?
   - A. To practise AI-assisted ABAP development on a safe, free system
   - B. To connect a coding agent to the company's production system
   - C. To replace SAP's ABAP tools with a general AI chat tool
   - D. To license Joule for developers for every learner

   Answer: A. The setup gives each learner a free trial ABAP system, SAP's development tools and a coding agent. It is a place to learn the pattern before anyone decides how to use it on real systems.

2. A partner wants to let an AI agent change ABAP in your development system. What should you ask first?
   - A. Which programming language the agent was originally written in
   - B. Whether the agent can also write Python next to SAP
   - C. Which systems it may write to and who approves each change
   - D. Whether the agent's model was trained only on SAP data

   Answer: C. An agent that writes into SAP needs clear limits and a person who approves its changes. Those two answers decide the risk far more than how the agent was built.

3. Why must company code never go into the ABAP trial?
   - A. The trial deletes every object after one hour
   - B. The trial can't activate custom ABAP classes
   - C. The trial only accepts code written by Joule
   - D. It is shared with other learners and meant for education only

   Answer: D. Trial users share one backend system and can see each other's objects. SAP describes it as an educational system, so only your own demo code belongs there.

4. Which statement about SAP's ABAP tools in October 2026 is accurate?
   - A. VS Code fully replaced Eclipse for all ABAP work in 2025
   - B. VS Code support started with ABAP Cloud, with more types added in 2026
   - C. Eclipse support for ABAP ended when VS Code arrived
   - D. Both editors need a Joule licence before they can connect

   Answer: B. SAP News says ABAP development in VS Code started in Q2 2026 with ABAP Cloud and that more object types follow through the year. Eclipse remains SAP's established ABAP editor, so teams often use both.

5. What can an agent using the ADT MCP server do in SAP?
   - A. Anything, because MCP gives it administrator rights
   - B. Nothing that changes the system, because MCP is read-only
   - C. What the developer's own connection allows, step by step
   - D. Only what Joule for developers has already approved

   Answer: C. The server works through the developer's own sign-in, so the agent inherits that person's permissions. That is why each tool call should be approved by the developer.

6. A sponsor says "the tools are free, so AI-assisted ABAP costs nothing". What is the soundest reply?
   - A. Agree: Copilot Free and the trial cover real projects
   - B. Agree: SAP includes Joule for developers in every ABAP licence
   - C. Disagree: Eclipse and ADT need paid licences for each developer
   - D. Disagree: real systems and AI help are licensed and paid

   Answer: D. The editors and the trial cost nothing, but production work needs a licensed ABAP system. AI help means SAP's licensed Joule for developers, a third-party agent subscription, or both.

## Deep layer

### Mental model: the agent borrows your hands

Picture a skilled assistant standing behind you at your desk. They can't touch the keyboard. They can only say "may I create this class?" and wait for you to nod. When you nod, they use your keyboard, your login and your permissions.

That is how a coding agent works with the ADT MCP server:

- **ADT** is your desk. It holds your connection to the ABAP system, signed in as you.
- **The ADT MCP server** is the set of things the assistant may ask to do: create an object, activate it, run unit tests, create a transport.
- **The coding agent** is the assistant. It reads your request, plans, and asks to use one tool at a time.
- **You** approve or refuse each request.

Two consequences follow. The agent can never do more than you can. And whatever it does, the system records as done by you.

### How it works

```mermaid
flowchart LR
  U[You] -->|prompt| A[Coding agent<br/>Copilot in VS Code]
  A -->|asks to call a tool| U
  A -->|MCP over HTTP<br/>127.0.0.1:2236| M[ADT MCP server<br/>inside ADT for VS Code]
  M -->|your ADT connection| S[(ABAP trial system<br/>on SAP BTP)]
  E[Eclipse with ADT] -->|same user| S
```

#### The pieces

- **The ABAP trial system.** A real SAP BTP ABAP environment, shared by many learners. You sign in with the same SAP account as your BTP trial.
- **ADT for VS Code.** SAP's extension for VS Code. You add a **destination**: a named connection to one ABAP system. SAP's tutorial uses an HTTP destination with an address of the form `https://<system-id>.abap.<region>.hana.ondemand.com` and a browser sign-in.
- **The ADT MCP server.** SAP's workshop material describes it as a local HTTP server inside the extension. It starts only when a destination is open in your workspace. Its default port is `2236`.
- **The coding agent.** This setup uses GitHub Copilot in **Agent** mode, the agent SAP's workshop uses. SAP's workshop says MCP tools are not available in Copilot's Ask or Edit modes.
- **Eclipse with ADT.** SAP's established tools. This setup uses Eclipse to connect with a service key and to run ABAP classes, which SAP's tutorials document step by step.

#### Some tools the server offers

SAP's workshop lists these, and says the list isn't complete:

| Tool | What it does | Changes the system? |
| --- | --- | --- |
| `abap_generators-list_generators` | Lists the RAP generators available | No |
| `abap_business_services-fetch_service_information` | Reads an OData service's details | No |
| `abap_creation-create_object` | Creates an ABAP object | Yes |
| `abap_activate-objects` | Activates objects so they run | Yes |
| `abap_run_unit_tests` | Runs ABAP unit tests | No |
| `abap_transport-create` | Creates a transport request | Yes |

Unit 11's lesson applies directly: read-only tools are low risk; tools that change the system need a person's approval. [Agent permissions and SAP authorizations](https://erpfde.com/topics/agent-permissions-and-sap-authorizations/) covers why.

#### Why the trial is shared

SAP's announcement of the ABAP trial explains that all trial users share one backend system. You can see objects others created, and they can see and change yours. Two rules follow for this course:

- Name every object with your own three-character suffix, written `###` in this topic. Pick initials plus a digit, such as `RT1`.
- Put nothing in it that you wouldn't post publicly.

### Build it yourself: your ABAP system, two editors and an agent

You will start the ABAP trial, connect Eclipse and run a tiny ABAP class, connect VS Code, turn on the ADT MCP server, and ask a coding agent to list tools on your behalf. Everything is free.

**Before you start:** complete [Set up your computer for this course](https://erpfde.com/topics/set-up-your-computer/), [Set up for Unit 17](https://erpfde.com/topics/set-up-for-unit-17/) and [Set up for Unit 18](https://erpfde.com/topics/set-up-for-unit-18/). They install Python, VS Code and Git, create your `orchestrate-course` folder with its `.venv`, `.env` and `.gitignore`, and create your SAP BTP trial. You also need a free GitHub account; [Git and GitHub for AI engineers](https://erpfde.com/topics/git-and-github-for-ai-engineers/) shows how to create one. This walkthrough doesn't repeat those steps.

```mermaid
flowchart LR
  S1[Step 1<br/>open folder] --> S2[Step 2<br/>ABAP trial]
  S2 --> S3[Step 3<br/>Eclipse + ADT]
  S3 --> S4[Step 4<br/>first ABAP class]
  S4 --> S5[Step 5<br/>ADT for VS Code]
  S5 --> S6[Step 6<br/>MCP server]
  S6 --> S7[Step 7<br/>coding agent]
  S7 --> S8[Step 8<br/>check]
  S8 --> S9[Step 9<br/>Git]
```

> **Note** New words in this walkthrough:
> - **Booster:** a guided wizard in the SAP BTP cockpit that sets up a service for you.
> - **Service key:** a small file of connection details and credentials for one service instance. Treat it like a password.
> - **Package:** a folder for ABAP objects. In the trial, yours goes inside `ZLOCAL`.
> - **Activate:** make an ABAP object's current version the one that runs.
> - **Destination:** a saved connection from VS Code to one ABAP system.
> - **Command Palette:** VS Code's search box for commands. Open it with `Ctrl+Shift+P` (macOS: `Cmd+Shift+P`).

#### What you need

- Your BTP trial from Unit 18, and its SAP account email and password.
- Windows 10 or newer, or macOS 14 or newer. These are SAP's stated minimums for Eclipse with ADT. Linux works for VS Code.
- Free disk space for Eclipse and its plugins.
- A free GitHub account.
- 60 to 90 minutes.
- Cost: free.

> **Warning** The service key from Step 2 contains credentials. Keep it **outside** your course folder, never paste it into code or chat, and never commit it to Git. The check in Step 8 warns you if one is inside the folder.

#### Step 1: Open your course folder and turn on the virtual environment

1. Open VS Code, choose **File > Open Folder**, and open `orchestrate-course`.
2. Open a terminal: **Terminal > New Terminal**.
3. If the prompt doesn't start with `(.venv)`, turn it on:

   - **Windows (PowerShell):**

     ```powershell
     .venv\Scripts\Activate.ps1
     ```

   - **macOS / Linux:**

     ```bash
     source .venv/bin/activate
     ```

4. Create the folder for this unit:

   ```bash
   mkdir unit09
   ```

#### Step 2: Start the ABAP trial

1. Sign in to the SAP BTP trial cockpit, the same place you used in Unit 18.
2. Click **Go To Your Trial Account**. If this is your first visit, choose a region and wait until setup finishes, then choose **Continue**.
3. On the left of your global account page, choose **Boosters**.
4. Find the tile **Prepare an Account for ABAP Trial** and press **Start**. SAP's tutorial says only one ABAP service instance can exist at a time; if you already have one, skip to item 6.
5. Wait a few minutes while the booster creates the service instance.
6. Choose **Go to instance**. This opens your trial subaccount's list of instances.
7. Get the **service key**. Open the ABAP instance's **...** menu. If it already has a key, open it; otherwise choose **Create Service Key**, give it a name such as `adt`, and create it. Then download the key, or copy its text into a new file.
8. Save the key as `abap-trial-key.json` in your **home folder or Documents**, not inside `orchestrate-course`.

**What success looks like:** the cockpit lists one ABAP instance with a status of created, and you have a key file outside your course folder.

> **Note** SAP changes the cockpit's layout from time to time. If a label here doesn't match, follow the cockpit's own labels; the goal is the same: one ABAP instance and one key file outside your course folder.

#### Step 3: Install Eclipse and ADT

1. In your browser, go to `https://www.eclipse.org/downloads/packages/` and download **Eclipse IDE for Java Developers** for your system. SAP's tutorial says recent Eclipse packages include their own Java, so you don't need to install Java.
2. Install or unpack it:
   - **Windows:** unzip the download into a folder such as `C:\eclipse`, then open `eclipse.exe`.
   - **macOS:** open the `.dmg` and drag **Eclipse** into **Applications**, then open it.
3. When Eclipse asks for a workspace, accept the suggested folder and click **Launch**. This is Eclipse's own folder; keep it outside `orchestrate-course`.
4. Choose **Help > Install New Software**.
5. In **Work with**, type `https://tools.hana.ondemand.com/latest` and press **Enter**.
6. Tick **ABAP Development Tools** and click **Next**, then **Next** again.
7. Accept the license agreement and click **Finish**.
8. When Eclipse asks about trust, click **Select All**, then **Trust Selected**. It may ask twice.
9. Click **Restart Now**.
10. After the restart, choose **Window > Perspective > Open Perspective > Other**, select **ABAP**, and click **Open**.

**What success looks like:** the Eclipse window title ends in "ABAP", and **File > New** offers ABAP project types.

#### Step 4: Connect Eclipse and run your first ABAP class

1. Choose **File > New > Other**, then **ABAP Cloud Project**, and click **Next**.
2. Select **SAP BTP ABAP Environment**, then **Use a Service Key**, and click **Next**.
3. Import the `abap-trial-key.json` file from Step 2 and click **Next**.
4. Click **Open Logon Page in Browser** and sign in with your BTP trial email and password. If the browser is signed in as someone else, copy the address into a private window.
5. Back in Eclipse, click **Finish**. Your trial system appears in the **Project Explorer** on the left.
6. Open the system, find the package `ZLOCAL`, right-click it and choose **New > ABAP Package**.
7. Name it `ZORCH_###` (your suffix instead of `###`), describe it as `Orchestrate course ###`, tick **Add to favorite packages**, and click **Next**.
8. Create a new transport request when asked, with any short description, and click **Finish**.
9. Right-click your new package and choose **New > ABAP Class**. Name it `ZCL_ORCH_HELLO_###`, describe it as `Hello from Orchestrate`, click **Next** twice, then **Finish**.
10. Replace the class's code with the code below. Change both `zcl_orch_hello_###` lines to your class name.

```abap
CLASS zcl_orch_hello_### DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC.

  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_orch_hello_### IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    " A made-up example. In a real system the block codes come from configuration.
    out->write( |Sales order 9000001 is on credit hold. Ask credit management to review it.| ).
  ENDMETHOD.
ENDCLASS.
```

11. Save (`Ctrl+S`, macOS `Cmd+S`) and activate (`Ctrl+F3`, macOS `Cmd+F3`).
12. Run it: select the class and press **F9**, or right-click it and choose **Run As > ABAP Application (Console)**.

**What success looks like** in the **Console** view:

```text
Sales order 9000001 is on credit hold. Ask credit management to review it.
```

| Part of the class | What it does |
| --- | --- |
| `INTERFACES if_oo_adt_classrun` | Lets ADT run the class as a console application |
| `METHOD if_oo_adt_classrun~main` | The code that runs when you press F9 |
| `out->write( ... )` | Prints a line to ADT's console |
| `|...|` | An ABAP string template, like a Python string |

#### Step 5: Install ADT for VS Code and connect

1. In VS Code, open the **Extensions** view: `Ctrl+Shift+X` (macOS `Cmd+Shift+X`).
2. Search for `ABAP Development Tools`. Choose the extension whose publisher is **SAP** and click **Install**.
3. Open the Command Palette and type `ABAP`. You should see commands such as **ABAP: New Destination...** and **ABAP: Activate**.
4. Find your system's address. Open `abap-trial-key.json` in a text editor and look for the address that contains `.abap.` and ends in `hana.ondemand.com`, such as `https://1a2b3c4d.abap.us10.hana.ondemand.com`. Copy it.
5. Run **ABAP: New Destination...** from the Command Palette.
6. Choose **HTTP**, paste the address, and enter a destination ID such as `TRIAL`.
7. Run **ABAP: Add Destination as Folder to the Workspace...** and pick `TRIAL`.
8. A browser window opens. Sign in with your BTP trial email and password.
9. Open your `.env` file in the course folder and add this line with your address, then save:

   ```text
   ABAP_SYSTEM_URL=https://1a2b3c4d.abap.us10.hana.ondemand.com
   ```

**What success looks like:** the system appears as a folder in VS Code's **Explorer**, next to `orchestrate-course`. Expand it and you can find `ZLOCAL` and your `ZORCH_###` package.

> **Tip** VS Code now has two folders open, which it calls a multi-root workspace. If it asks whether to save the workspace, choose **Save** and keep the `.code-workspace` file in your home folder, not the course folder.

#### Step 6: Turn on the ADT MCP server

1. Open the Command Palette and run **Preferences: Open Settings (UI)**.
2. In the settings search box, type `adt mcp`.
3. Tick **Adt: Enable MCP Server**.
4. If VS Code asks to reload, click the button to reload it.
5. Check that it runs. Either look for the notification **ADT MCP Server running on port 2236** in the bottom right, or run **MCP: List Servers** from the Command Palette, select **ADT MCP Server**, and choose **Start Server** if it isn't running.

**What success looks like:** **MCP: List Servers** shows **ADT MCP Server** as running.

> **Note** The server starts only while your ABAP destination folder is open in the workspace. If you close that folder, the agent loses its ABAP tools.

#### Step 7: Connect a coding agent and try a safe tool

1. Hover over the **Copilot** icon in VS Code's Status Bar at the bottom, and choose **Use AI Features**.
2. Choose **Continue with GitHub** (or the GitHub option shown) and sign in with your GitHub account. If you have no Copilot plan, VS Code's documentation says you are signed up for **Copilot Free**.
3. Open Copilot Chat: `Ctrl+Shift+I` (macOS `Cmd+Shift+I`).
4. In the chat box's mode picker, choose **Agent**.
5. Click the **Configure Tools** icon (a wrench) in the chat box. Under **ADT MCP Server**, check that the tools are ticked.
6. Type this prompt and press **Enter**:

   ```text
   List all available ABAP RAP generators using the MCP tool.
   ```

7. Copilot asks to run `abap_generators-list_generators`. Read the request, then allow it **once**. Don't choose an option that allows it always.

**What success looks like:** the agent replies with a list of generators that includes one called **OData UI Service from Scratch**. This tool only reads, so nothing in the system changed.

> **Warning** Never turn on automatic approval for ABAP tools. Tools such as `abap_creation-create_object` and `abap_activate-objects` change the system as **you**. Allow each one after reading what it will do.

#### Step 8: Run the Unit 9 check

Unit 9 adds no lines to `requirements.txt`: everything new is an editor or a service, not a Python library.

1. In the course folder (not in `unit09`), create `check_unit09.py`, paste the code below and save. It uses only built-in Python, like the earlier checks.

```python
"""Check that your computer is ready for Unit 9 (ABAP development tools and a coding agent).

Run it from your course folder, in VS Code's terminal:  python check_unit09.py
It uses built-in Python only. It looks for VS Code and its extensions, your ABAP system address
in .env, a service key left where Git could pick it up, and the ADT MCP server on this computer.
It changes nothing and sends nothing outside your computer.
"""
import os
import shutil
import socket
import subprocess
import sys
from urllib.parse import urlparse

DEFAULT_MCP_PORT = 2236   # the ADT MCP server's default port in SAP's workshop material
problems = 0


def report(ok: bool, label: str, fix: str = "", optional: bool = False) -> None:
    """Print one line: OK, MISSING (must fix) or LATER (optional for now)."""
    global problems
    if ok:
        print(f"  OK       {label}")
    elif optional:
        print(f"  LATER    {label}  ->  {fix}")
    else:
        problems += 1
        print(f"  MISSING  {label}  ->  {fix}")


def read_env(path: str = ".env") -> dict:
    """Read KEY=value lines from .env without any library. Ignores comments and blank lines."""
    values = {}
    if not os.path.exists(path):
        return values
    with open(path, encoding="utf-8") as handle:
        for line in handle:
            line = line.strip()
            if line and not line.startswith("#") and "=" in line:
                key, value = line.split("=", 1)
                values[key.strip()] = value.strip().strip('"').strip("'")
    return values


def vscode_extensions() -> list:
    """IDs of the VS Code extensions installed for this user, or [] if `code` can't be run."""
    command = shutil.which("code") or shutil.which("code.cmd")
    if not command:
        return []
    try:
        done = subprocess.run([command, "--list-extensions"],
                              capture_output=True, text=True, timeout=60)
    except (OSError, subprocess.SubprocessError):
        return []
    return [line.strip().lower() for line in done.stdout.splitlines() if line.strip()]


def stray_service_keys() -> list:
    """JSON files in the course folder that look like a service key (they hold a clientsecret)."""
    found = []
    for folder, subfolders, files in os.walk("."):
        subfolders[:] = [s for s in subfolders if not s.startswith(".") and s != "node_modules"]
        for name in files:
            if name.lower().endswith(".json"):
                path = os.path.join(folder, name)
                try:
                    with open(path, encoding="utf-8", errors="ignore") as handle:
                        if "clientsecret" in handle.read(200_000):
                            found.append(path)
                except OSError:
                    pass
    return found


def port_open(port: int) -> bool:
    """True if something on this computer accepts connections on the given port."""
    try:
        with socket.create_connection(("127.0.0.1", port), timeout=2):
            return True
    except OSError:
        return False


print("\n1. Python")
v = sys.version_info
report(v >= (3, 11), f"Python {v.major}.{v.minor}.{v.micro}",
       "the course needs Python 3.11 or newer (see Set up for Unit 17, Step 1)")
report(sys.prefix != sys.base_prefix, "virtual environment is active", "activate .venv (Step 1)")

print("\n2. VS Code and its extensions")
has_code = bool(shutil.which("code") or shutil.which("code.cmd"))
report(has_code, "code command",
       "macOS: in VS Code run 'Shell Command: Install 'code' command in PATH'; "
       "then open a new terminal")
extensions = vscode_extensions()
abap = [e for e in extensions if e.startswith("sapse.") and ("abap" in e or "adt" in e)]
report(bool(abap), f"ABAP extension: {abap[0]}" if abap else "ABAP extension",
       "install ABAP Development Tools for Visual Studio Code (Step 5)")
copilot = [e for e in extensions if "copilot" in e]
report(bool(copilot), f"Copilot extension: {copilot[0]}" if copilot else "Copilot extension",
       "sign in to Copilot in VS Code (Step 7); newer VS Code may build it in", optional=True)

print("\n3. Your ABAP trial system")
env = read_env()
report(os.path.exists(".env"), ".env file", "create it as in Set up your computer")
url = env.get("ABAP_SYSTEM_URL", "")
parts = urlparse(url)
looks_right = parts.scheme == "https" and ".abap." in parts.netloc
report(looks_right, f"ABAP_SYSTEM_URL = {url}" if url else "ABAP_SYSTEM_URL in .env",
       "add your trial system's https://...abap...hana.ondemand.com address (Step 5)")
strays = stray_service_keys()
report(not strays, "no service key inside the course folder",
       "move " + ", ".join(strays) + " out of the course folder (Step 2)")

print("\n4. ADT MCP server")
try:
    port = int(env.get("ADT_MCP_PORT", DEFAULT_MCP_PORT))
except ValueError:
    port = DEFAULT_MCP_PORT
report(port_open(port), f"ADT MCP server answers on port {port}",
       "in VS Code: open your ABAP destination folder and turn on 'Adt: Enable MCP Server' (Step 6)")

print()
if problems:
    print(f"{problems} item(s) to fix. Fix them in order, then run this again.")
    sys.exit(1)
print("All set. Your computer is ready for Unit 9.")
```

2. Run it in VS Code's terminal, with the ABAP destination folder still open:

   ```bash
   python check_unit09.py
   ```

**What success looks like** (your versions, IDs and address will differ):

```text
1. Python
  OK       Python 3.13.16
  OK       virtual environment is active

2. VS Code and its extensions
  OK       code command
  OK       ABAP extension: sapse.<extension-id>
  OK       Copilot extension: github.copilot-chat

3. Your ABAP trial system
  OK       .env file
  OK       ABAP_SYSTEM_URL = https://1a2b3c4d.abap.us10.hana.ondemand.com
  OK       no service key inside the course folder

4. ADT MCP server
  OK       ADT MCP server answers on port 2236

All set. Your computer is ready for Unit 9.
```

`LATER` lines are fine. A `LATER` line for the Copilot extension can appear on VS Code versions that build Copilot in; if Step 7 worked, you are ready. `MISSING` lines must be fixed; each names the step that fixes it.

#### Step 9: Save your work in Git

1. Check what Git sees:

   ```bash
   git status
   ```

   You should see `check_unit09.py` and, after the exercise, `unit09/`. You must **not** see `.env` or any `.json` key file.

2. Save:

   ```bash
   git add check_unit09.py
   git commit -m "Set up Unit 9: ABAP tools and a coding agent"
   ```

Your ABAP class lives in the trial system, not on your computer. The exercise records what the agent did in a file that Git can keep.

#### How the code works

| Part | What it does |
| --- | --- |
| `report()` | Prints `OK`, `MISSING` or `LATER`, and counts what must be fixed |
| `read_env()` | Reads `.env` line by line with built-in Python, so the check needs no library |
| `vscode_extensions()` | Runs `code --list-extensions` and returns the installed extension IDs |
| `abap = [...]` | Looks for an extension from SAP (`sapse.`) with `abap` or `adt` in its ID |
| `stray_service_keys()` | Searches the course folder for `.json` files holding a `clientsecret`, the sign of a service key |
| `port_open()` | Tries to connect to `127.0.0.1` on the MCP port; it doesn't send any MCP messages |
| `ADT_MCP_PORT` | Optional `.env` line if you changed the server's port in VS Code's settings |

#### If something goes wrong

| What you see | What it means | What to do |
| --- | --- | --- |
| `python` is not recognized, or `command not found` | Python isn't installed, or the terminal can't find it | Windows: repeat Unit 2, Step 1, then open a new terminal. macOS/Linux: use `python3` until `.venv` is active |
| `MISSING code command` | VS Code's `code` command isn't on the path | macOS: in VS Code, run **Shell Command: Install 'code' command in PATH**. Windows: reinstall VS Code with **Add to PATH** ticked. Then open a new terminal |
| The **Boosters** page has no ABAP tile, or the booster fails | The trial region or account isn't set up for the ABAP trial | Check the region chosen in Step 2; if it still fails, delete the failed instance and run the booster again |
| Eclipse can't reach `tools.hana.ondemand.com` | A proxy or firewall blocks the update site | In Eclipse, **Window > Preferences > General > Network Connections**, set your company proxy; or ask IT to allow the site |
| **Open Logon Page in Browser** shows an error, or signs in as the wrong person | The browser has another SAP sign-in | Copy the logon address into a private window and sign in there |
| Wrong key, or the key is rejected | The key belongs to another instance, or was copied incompletely | Download the key again from the ABAP instance and import that file |
| VS Code can't connect to the destination | The address is wrong, or the browser sign-in didn't finish | Check the address against the key file, then run **ABAP: Add Destination as Folder to the Workspace...** again |
| `MISSING ADT MCP server answers on port 2236` | The server isn't running, or the destination folder is closed | Open the destination folder, untick and tick **Adt: Enable MCP Server**, and restart VS Code |
| Copilot has no ADT tools | Chat isn't in Agent mode, or the tools are switched off | Choose **Agent** in the mode picker, then tick the server under **Configure Tools** |
| Copilot says you have reached a limit | Copilot Free's monthly allowance is used up | Wait for the monthly reset, or do the steps by hand in Eclipse, which needs no agent |
| An object name is already taken | Another learner used the same name in the shared trial | Pick a different `###` suffix and use it everywhere |
| `MISSING no service key inside the course folder` | A key file is where Git could commit it | Move the file to your home folder; if it was already committed, delete the key in the cockpit and create a new one |

### Where this shows up in SAP

- **Systems.** SAP's VS Code tutorial lists three kinds of system ADT for VS Code connects to: SAP BTP ABAP environment, SAP S/4HANA Cloud ABAP environment, and SAP S/4HANA 2025 or higher, the last also through an RFC connection set up in SAP Logon. A customer's development system is one of these.
- **ABAP Cloud first.** SAP News says VS Code support started with ABAP Cloud and that more object types follow through 2026. Unit 9's topics stay within ABAP Cloud and RAP, the clean-core path this course has followed since Unit 5.
- **Third-party agents.** SAP News names GitHub Copilot and Amazon Q as agents that can use the ABAP MCP server. SAP's workshop says any agent that supports VS Code's virtual workspace file system can work, and confirms GitHub Copilot.
- **SAP's own AI.** Joule for developers, ABAP AI capabilities, is SAP's licensed assistant inside ADT. SAP-ABAP-1, SAP's model tuned on ABAP code, is discussed in [When to fine-tune](https://erpfde.com/topics/when-to-fine-tune/). The next topic compares them with third-party agents.

| Need | Learn with (this setup) | On a customer project |
| --- | --- | --- |
| ABAP system | Shared ABAP trial | Licensed development system, own client and users |
| Editor | Eclipse and VS Code with ADT | The same tools, versions set by the company |
| Coding agent | Copilot Free in Agent mode | An approved agent plan, possibly Joule for developers |
| Approvals | You allow each tool call | Tool approvals plus code review and transports |

### Production concerns

- **Authorizations.** The agent acts as the signed-in developer. On a real system, its reach is the developer's reach: keep agents to development systems and never sign in as a user with production access.
- **Approve every change.** Allow write tools one call at a time. Code review and the transport process still apply to agent-made objects.
- **Code leaves the building.** A third-party agent sends your code and prompts to its model provider. Check the agent's data terms and your company's rules before using it on customer code.
- **Tool poisoning.** An MCP server's tool descriptions go straight into the agent's instructions. Install MCP servers only from trusted sources, as [Prompt injection and tool poisoning](https://erpfde.com/topics/prompt-injection-and-tool-poisoning/) explains.
- **Secrets.** A service key is a credential. Store it outside source folders, rotate it if it leaks, and prefer personal browser sign-in over shared keys.
- **Clean core.** ABAP Cloud keeps custom code on released APIs. An agent should follow the same rule; reject changes that reach into SAP internals.

### Pitfalls

- **Leaving the destination folder closed.** The MCP server only runs with it open, so the agent quietly loses its ABAP tools.
- **Choosing "always allow".** It saves clicks and removes your only control over what the agent changes.
- **Reusing tutorial names.** In a shared trial, names like `ZCL_HELLO` clash. Always add your suffix.
- **Committing the key.** A key in the course folder is one `git add .` away from GitHub.
- **Expecting every editor in VS Code.** Some object types are still Eclipse-only in 2026. Keep Eclipse installed.
- **Treating the trial as permanent.** It ends with your BTP trial. Keep the code that matters in Git as text.

### Exercise

Let the agent make one change, with you approving each step, and keep a log. The next topic, on coding agents for SAP developers, reuses this log.

1. In `unit09`, create `agent_log.md` with this content and save:

   ```text
   # Unit 9 agent log

   | Date | Prompt | Tool called | Changes the system? | Allowed? | Result |
   | --- | --- | --- | --- | --- | --- |
   ```

2. In Copilot Chat (Agent mode), send this prompt, with your suffix instead of `###`:

   ```text
   In package ZORCH_###, create an ABAP class ZCL_ORCH_AGENT_### that implements
   if_oo_adt_classrun and writes one line: "Agent test: sales order 9000001 is on credit hold."
   Use the ADT MCP tools, then activate the class. Ask before every tool call.
   ```

3. For each tool the agent asks to call, read the request first. Allow it once if it matches what you asked. Refuse it if it touches anything outside `ZORCH_###`.
4. Add one row to `agent_log.md` for every tool call, allowed or refused.
5. In Eclipse, refresh your package (select it and press **F5**), select `ZCL_ORCH_AGENT_###`, and press **F9**. Check the console line.
6. Under the table, write two sentences: which tool call you were most careful about, and why.
7. Commit:

   ```bash
   git add unit09/agent_log.md
   git commit -m "Unit 9: first agent log"
   ```

**Done when** the agent-made class prints its line in Eclipse's console, `agent_log.md` has a row for every tool call, and `python check_unit09.py` ends with `All set`.

### Check yourself

1. In the mental model, why can the agent never do more than you in the ABAP system?
   - A. The MCP server strips every write tool before the agent sees it
   - B. It works through your ADT connection, so it has your permissions
   - C. The trial system blocks every change that an AI agent makes
   - D. Copilot Free can only call MCP tools that read data

   Answer: B. The ADT MCP server uses the destination you signed in to. Every tool call runs as you, with your permissions, and the system records it as yours.

2. The check says `MISSING ADT MCP server answers on port 2236`, but the setting is ticked. What is the most likely cause?
   - A. The Copilot extension is not installed in VS Code yet, so nothing starts
   - B. The `.env` file has the wrong ABAP system address
   - C. The ABAP destination folder isn't open in the workspace
   - D. Eclipse is still running and is holding on to the same port

   Answer: C. SAP's workshop says the server starts only when a destination is active in the workspace. Opening the destination folder, or toggling the setting, usually brings it back.

3. Which of these tool calls deserves the closest reading before you allow it?
   - A. `abap_generators-list_generators`
   - B. `abap_run_unit_tests`
   - C. `abap_business_services-fetch_service_information`
   - D. `abap_creation-create_object`

   Answer: D. Creating an object changes the system as you. Listing generators, reading service details and running tests leave it unchanged, so the risk is lower.

4. Why does the setup keep `abap-trial-key.json` outside the course folder?
   - A. Eclipse can only import keys stored in the home folder
   - B. It holds credentials, and the course folder is pushed with Git
   - C. VS Code would treat the key as a second ABAP destination
   - D. The check script deletes any service key it finds there

   Answer: B. A service key carries credentials for your ABAP instance. Anything in the course folder can end up in a commit, so the check only warns about a key there; it never deletes it.

5. A teammate suggests turning on automatic approval so the agent can finish the exercise faster. What would you do?
   - A. Agree, because the trial is shared and nothing there matters
   - B. Agree, but only for tools whose names start with `abap_`
   - C. Refuse, and keep allowing write tools one call at a time
   - D. Refuse, and switch Copilot back to Ask mode instead

   Answer: C. Approval is your only control over what the agent changes as you. Ask mode would remove the MCP tools altogether, which doesn't teach the pattern the unit needs.

6. In the console class from Step 4, what does `INTERFACES if_oo_adt_classrun` do?
   - A. Lets ADT run the class as a console app with F9
   - B. Publishes the class as an OData service for the agent
   - C. Gives the class permission to change other objects
   - D. Connects the class to the tools of the ADT MCP server

   Answer: A. The interface's `main` method is what ADT calls when you run the class, and `out->write` prints to the console. It has nothing to do with services or MCP.

7. Another learner already created `ZCL_ORCH_HELLO_RT1` in the trial. What does that tell you?
   - A. The trial copied your class to every other learner
   - B. Your BTP trial has expired and the system was reset
   - C. The trial is shared, so pick a different suffix
   - D. Your service key belongs to another learner

   Answer: C. All ABAP trial users share one system and can see each other's objects. A unique suffix avoids clashes; nothing in the trial should be private.

8. A customer wants to use a third-party coding agent on its ABAP code. Which concern matters most before saying yes?
   - A. Whether the agent's chat window fits next to the editor
   - B. Whether the agent can also run Python code locally
   - C. Where the code and prompts go, and the agent's data terms
   - D. Whether the agent supports the Eclipse dark theme

   Answer: C. A third-party agent sends code and prompts to its model provider. The customer's data rules and the agent's terms decide whether that is acceptable, before any productivity gain.

## Sources

- [ABAP Development Tools for Visual Studio Code (SAP Developer Center tutorial)](https://developers.sap.com/tutorials/abap-environment-adt-vscode.html): search "ABAP Development Tools" and install the SAP-published extension; includes the built-in ADT MCP Server; backends are SAP BTP ABAP environment, SAP S/4HANA Cloud ABAP environment or SAP S/4HANA 2025 and higher; ABAP New Destination, HTTP, URL https://<system-id>.abap.<region>.hana.ondemand.com, browser logon; keyboard shortcuts
- [Exercise 1: ADT MCP Server (SAP-samples/abap-platform-rap130 on GitHub)](https://github.com/SAP-samples/abap-platform-rap130/blob/main/exercises/ex01/README.md): local HTTP server in the extension, described there as experimental; setting adt.mcpServer.enabled; default port 2236; MCP List Servers; GitHub Copilot in Agent mode, Configure Tools; tool names such as abap_creation-create_object and abap_activate-objects
- [Create an SAP BTP ABAP Environment Trial User (SAP Developer Center tutorial)](https://developers.sap.com/tutorials/abap-environment-trial-onboarding.html): trial cockpit, Go To Your Trial Account, Boosters, Prepare an Account for ABAP Trial, Start; one service instance at a time; Go to instance
- [Create an ABAP Cloud Project (SAP Developer Center tutorial)](https://developers.sap.com/tutorials/abap-environment-create-abap-cloud-project.html): File > New > Other > ABAP Cloud Project; SAP BTP ABAP Environment; Use a Service Key; Open Logon Page in Browser
- [Create Your First ABAP Console Application (SAP Developer Center tutorial)](https://developers.sap.com/tutorials/abap-environment-console-application.html): package under ZLOCAL with a new transport request; class with if_oo_adt_classrun; out->write; Run As ABAP Application (Console) or F9
- [Install ABAP Development Tools (SAP Developer Center tutorial)](https://developers.sap.com/tutorials/abap-install-adt.html): Eclipse bundles a Java runtime; Windows 10 or higher, macOS 14 or higher; Help > Install New Software; https://tools.hana.ondemand.com/latest; Trust Selected; Restart Now; ABAP perspective
- [With agentic AI, ABAP takes evolution to the next level (SAP News, 18 August 2026)](https://news.sap.com/2026/08/with-agentic-ai-abap-takes-evolution-to-the-next-level/): ABAP in VS Code from Q2 2026, ABAP Cloud first and more object types through the year; ABAP MCP server in Eclipse and VS Code generally available in Q2 2026; GitHub Copilot and Amazon Q named; move to usage-based billing in AI units
- [It's trial time for ABAP in SAP Cloud Platform (SAP blog, 2019)](https://blogs.sap.com/2019/09/28/its-trialtime-for-abap-in-sap-cloud-platform): trial users share one backend system and can see and change each other's objects; educational use only; upload only your own demo code; no business roles or custom authorizations
- [Set up GitHub Copilot in VS Code (VS Code documentation)](https://code.visualstudio.com/docs/setup/copilot): Copilot icon in the Status Bar, Use AI Features; accounts without a subscription are signed up for Copilot Free; chat.disableAIFeatures hides AI features
- [GitHub Copilot individual plans (GitHub Docs)](https://docs.github.com/en/copilot/concepts/billing/individual-plans): Copilot Free has up to 2,000 completions a month and limited chat and agent usage with automatic model selection
