GitHub Copilot: Zero to Agents — SAP Edition — Hands-On Lab Guide

Duration: ~2.5 hours of hands-on exercises (within the ~5h workshop / 2-part series)
Format: Step-by-step lab exercises aligned to workshop sections
Audience: SAP developers — ABAP, CAP/BTP, and integration engineers
Samples: capire/bookshop (CAP) · ABAP sample repos (optional Lab 4)

Companion documents: Workshop Guide · Slides · SAP Developers enablement workshop.

Important: Labs 1–3 run entirely in VS Code on the CAP bookshop — no live SAP backend. Lab 4 uses ABAP sample source in Eclipse (also backend-free); a live SAP system only adds execution/ATC steps.


Lab Overview

You will build the full Copilot customization stack on a real SAP CAP service, then (optionally) prove the same stack in Eclipse over ABAP. By the end you will have a .github/ folder of instructions, prompts, skills, and agents, plus a .vscode/mcp.json wired to the SAP MCP servers.

Prerequisites

Requirement Details
GitHub Account With Copilot Pro, Business, or Enterprise license
VS Code Latest stable (or Insiders)
Copilot Extensions GitHub Copilot + Copilot Chat
Node.js Version 18 or higher
SAP CDS toolkit npm install -g @sap/cds-dk
GitHub Copilot CLI For Lab 3 — see https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli
Eclipse (optional) Eclipse 2024-09+ + ADT + Copilot plugin 0.20.0+ — for Lab 4

Setup Checkpoint

git clone https://github.com/capire/bookshop
cd bookshop
npm install
npm install -g @sap/cds-dk
cds watch

Lab Summary

Lab Workshop Sections Duration Focus
1 §1b–2b 30 min Modes, inline, context on CAP
2 §3–6 50 min Instructions, prompts, skills, agents
3 §7–9 40 min SAP MCP, CLI, cloud agents
4 (optional) §10 30 min ABAP in Eclipse — full stack

Lab 1: CAP Foundations — Modes, Inline & Context (30 min)

Exercise 1.1 — Inline Completion & Chat (8 min)

Steps

Step 1: Open srv/cat-service.cds and its handler. Type a guiding comment:

// Add a handler that lowercases the book title before returning results

Step 2: Accept useful ghost text with Tab. Then select it and open inline chat (Ctrl+I):

Make this handler async and guard against an empty result set.

Success Criteria

  • ✅ Accepted an inline completion from a comment
  • ✅ Refined the code with inline chat

Exercise 1.2 — Ask, Plan, Agent (12 min)

Steps

Step 1 — Ask:

@workspace Explain this CAP project — the data model in db/, the services in srv/, and how they connect.

Step 2 — Plan:

I want to add a submitOrder(book, quantity) action to the CatalogService. Give me a step-by-step plan before any code.

Step 3 — Agent:

Implement step 1 from that plan.

Success Criteria

  • ✅ Got a codebase-aware answer from Ask
  • ✅ Plan mode proposed changes without editing files
  • ✅ Agent mode edited files and ran a command

Exercise 1.3 — Context Targeting (10 min)

Steps

Step 1: Ask vaguely: How does the catalog service work? — note the generic answer.

Step 2: Ask precisely:

@workspace #file:srv/cat-service.cds How does the catalog service work, and where would I add validation?

Success Criteria

  • ✅ Observed the precision gain from @workspace + #file

Lab 2: The Customization Stack (50 min)

Exercise 2.1 — Custom Instructions (12 min)

Steps

Step 1: Chat → Gear → Generate Agent Instructions → save to .github/copilot-instructions.md.

Step 2: Create .github/instructions/CAP.instructions.md:

---
applyTo: "srv/**"
---
# CAP Service Instructions
- Expose entities through services — never query the db model directly.
- Validation errors use the CAP req.error(code, message) API.
- Prefer async/await in custom handlers.

Step 3: Ask Add a new action to the CatalogService and confirm it follows the conventions.

Success Criteria

  • ✅ Project + scoped instruction files exist
  • ✅ A new generation followed the conventions automatically

Exercise 2.2 — Prompt File (12 min)

Steps

Step 1: Create .github/prompts/cap-tests.prompt.md:

---
mode: 'agent'
description: 'Generate cds.test coverage for a CAP service action'
tools: ['codebase', 'search', 'editFiles', 'runCommands']
---

# CAP Test Coverage
## Objective
Generate tests for the target action using the CAP test runtime (cds.test).
## Requirements
- Cover the happy path and the out-of-stock edge case
- Add a package.json test script if missing
## Success Criteria
- Tests run with `npm test` and pass

Step 2: Run it against submitOrder, then npm test.

Success Criteria

  • ✅ Prompt file ran a multi-step task
  • ✅ Tests were generated and run

Exercise 2.3 — Agent Skill (13 min)

Steps

Step 1: Create .github/skills/cap-service/SKILL.md:

---
name: cap-service
description: Guide for adding CAP entities, services, and actions.
  Use this when asked to add new entities, services, actions, or endpoints.
---

When adding to this CAP project:
1. Define/extend the entity in db/ (CDS).
2. Expose it via a service in srv/ — never the db model directly.
3. Implement custom logic in the matching .js handler with async/await.
4. Use req.error for validation failures.
5. Add cds.test coverage including edge cases.

Step 2: Prompt Add a Warehouses entity with stock management and watch Copilot auto-select the skill.

Success Criteria

  • ✅ Copilot auto-selected the skill from your prompt (no manual invocation)

Exercise 2.4 — Custom Agent (13 min)

Steps

Step 1: Create .github/agents/CDSReviewer.agent.md:

---
tools: ['codebase', 'search', 'usages', 'problems']
description: Review CAP services for validation, error handling, and model exposure
model: Claude Sonnet 4
---

You are a CAP/CDS code reviewer. For each finding provide severity, file/line,
and a concrete fix. Check: entities exposed only through services, req.error usage,
async handlers, and cds.test coverage. Be direct — say "change this to..."

Step 2: Select CDSReviewer in the mode picker and ask it to review srv/cat-service.cds and the submitOrder handler.

Success Criteria

  • ✅ The agent appears in the mode picker and stays in persona
  • ✅ It reports findings without editing files (read-only tools)

Lab 3: SAP MCP, CLI & Cloud Agents (40 min)

Exercise 3.1 — The SAP MCP Servers (15 min)

Steps

Step 1: Create .vscode/mcp.json:

{
  "servers": {
    "fiori-mcp": { "type": "stdio", "command": "npx", "args": ["--yes", "@sap-ux/fiori-mcp-server@latest", "fiori-mcp"] },
    "ui5-mcp-server": { "type": "stdio", "command": "npx", "args": ["-y", "@ui5/mcp-server"] },
    "cds-mcp": { "type": "stdio", "command": "npx", "args": ["-y", "@cap-js/mcp-server"] },
    "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp/" }
  }
}

Step 2: Command Palette → MCP: List servers to confirm.

Step 3: In Agent mode:

Add a SAP Fiori elements list report app for the Books entity, with an object page for details.

Step 4: Ask the UI5 server to review the app against UI5 guidelines and run the linter.

Success Criteria

  • ✅ SAP + GitHub MCP servers registered and visible
  • ✅ A Fiori elements app scaffolded on the CAP service
  • ✅ UI5 guidelines/linting applied via the UI5 server

Exercise 3.2 — The Agentic CLI (12 min)

Steps

Step 1: From a standalone terminal in the bookshop repo, run copilot and approve the directory.

Step 2: Ask Explain this CAP project and list all entities and services.

Step 3: Plan mode (Shift+Tab): Plan how to add pagination to the Books listing. Then implement with @srv/cat-service.cds context.

Step 4 (bonus): /review your changes, or /delegate Add pagination tests and open a PR.

Success Criteria

  • ✅ Ran a codebase-aware CLI session with @file context and plan mode
  • ✅ Used at least one slash command

Exercise 3.3 — Cloud Agents (13 min)

Note: Requires Coding Agent enabled and branch protection on main.

Steps

Step 1: Create an Issue: Add input validation to submitOrder (positive integer quantity, existing book).

Step 2: Assign Copilot → watch it branch, implement, and open a PR.

Step 3: Add Copilot as a reviewer on the PR → review the AI comments. Confirm your .github/ customization shaped the output.

Success Criteria

  • ✅ Coding Agent produced a PR from an Issue
  • ✅ Copilot Code Review provided comments
  • ✅ Your instructions/skills influenced the autonomous output

Lab 4 (Optional): ABAP in Eclipse — The Full Stack (30 min)

Important: Uses ABAP sample source in Eclipse — backend-free. Requires Eclipse 2024-09+, ADT, and the Copilot plugin 0.20.0+. The model is not ABAP-fine-tuned and agent mode on ADT's generated/virtual files can vary — review every edit.

Setup

Install Eclipse + ADT + the latest Copilot plugin, then clone and import the ABAP samples (File → Import → General → Projects from Folder or Archive):

git clone https://github.com/SAP-samples/abap-cheat-sheets
git clone https://github.com/SAP-samples/abap-platform-refscen-flight
git clone https://github.com/SAP-samples/cloud-abap-rap

Exercise 4.1 — Ask + Custom Instructions (10 min)

Steps

Step 1: From abap-platform-refscen-flight, open a class and ask:

What is this program doing? Draw the execution flow.

Step 2: Add .github/copilot-instructions.md:

# ABAP conventions
- Prefer modern ABAP 7.5+ syntax (inline declarations, constructor expressions).
- Always check sy-subrc after a SELECT.

Success Criteria

  • ✅ Got an accurate explanation in Eclipse over ABAP source
  • ✅ A custom instruction is in place

Exercise 4.2 — Agent Mode (12 min)

Steps

Step 1: Select Agent mode and prompt:

Refactor this class to modern ABAP 7.5+ syntax and add a helper method that validates its key input, following our conventions.

Step 2: Review each proposed edit before accepting. Spot-check behavior on ADT's virtual files.

Success Criteria

  • ✅ Agent mode proposed edits over ABAP source
  • ✅ Output reflected the custom instruction
  • ✅ You reviewed every change before accepting

Exercise 4.3 — (Optional, live SAP system) Execution & ATC (8 min)

Important: Requires a connected SAP system or ABAP trial.

Steps

Step 1: Comment-driven completion — * TODO: select all flights for a carrier from SFLIGHT into an internal table.

Step 2: Optimize this SELECT and explain why, then validate through ATC and code review.

Success Criteria

  • ✅ Validated generated ABAP through normal review (ATC / transport / code review)

Lab guide for the GitHub Copilot: Zero to Agents — SAP Edition