sap
БесплатноБез исполняемых скриптовНе проверенConnect to SAP S/4HANA (OData APIs), SAP Business One (Service Layer) and build SAP CAP applications on SAP BTP with Node.js. Use when a user asks to read or…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
SAP
Overview
SAP S/4HANA exposes business data through OData services (the V2 services API_BUSINESS_PARTNER, API_SALES_ORDER_SRV, API_PURCHASEORDER_PROCESS_SRV, API_MATERIAL_STOCK_SRV; V4 variants also exist), SAP Business One exposes the Service Layer (REST/OData under /b1s/v1), and the SAP Cloud Application Programming Model (CAP, @sap/cds 10) builds new services for SAP BTP. This skill covers authentication, reading and creating documents, a working CAP service, and integration patterns. The API catalog lives in the SAP Business Accelerator Hub (api.sap.com, formerly API Business Hub); your own tenant needs a communication arrangement or technical user.
Instructions
Step 1: Authentication and connectivity
export SAP_TOKEN_URL="https://acme-prod.authentication.eu10.hana.ondemand.com/oauth/token"
export SAP_CLIENT_ID="sb-acme-s4-integration"
export SAP_CLIENT_SECRET="..." # from your secret store
export SAP_BASE_URL="https://my300123-api.s4hana.cloud.sap/sap/opu/odata/sap"
The token URL and base URL come from your tenant (communication arrangement or BTP service key); the values above only show the shape. With OAuth2 client credentials:
async function getSAPToken(): Promise<string> {
const basic = Buffer.from(`${process.env.SAP_CLIENT_ID}:${process.env.SAP_CLIENT_SECRET}`).toString("base64");
const res = await fetch(process.env.SAP_TOKEN_URL!, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded", Authorization: `Basic ${basic}` },
body: "grant_type=client_credentials",
});
if (!res.ok) throw new Error(`Token request failed: ${res.status}`);
return (await res.json()).access_token;
}
OData V2 write requests need a CSRF token: do a GET on the service root with X-CSRF-Token: fetch, read the x-csrf-token response header, send it on the POST/PATCH/DELETE, and re-fetch when the server answers 403. Keep the session cookies from that GET and send them along.
async function getCSRF(token: string, service: string) {
const res = await fetch(`${process.env.SAP_BASE_URL}/${service}/`, {
headers: { Authorization: `Bearer ${token}`, "X-CSRF-Token": "fetch", Accept: "application/json" },
});
const cookie = res.headers.getSetCookie().map((c) => c.split(";")[0]).join("; ");
return { csrf: res.headers.get("x-csrf-token")!, cookie };
}
async function sapApi(method: string, path: string, token: string, body?: unknown) {
const service = path.split("/")[1];
const write = method !== "GET";
const extra = write ? await getCSRF(token, service) : null;
const res = await fetch(`${process.env.SAP_BASE_URL}${path}`, {
method,
headers: {
Authorization: `Bearer ${token}`, "Content-Type": "application/json", Accept: "application/json",
...(extra ? { "X-CSRF-Token": extra.csrf, Cookie: extra.cookie } : {}),
},
body: body ? JSON.stringify(body) : undefined,
});
if (!res.ok) throw new Error(`SAP ${res.status}: ${await res.text()}`);
return res.json();
}
OData V2 JSON wraps results: lists are in response.d.results, a single entity in response.d.
The SAP Cloud SDK (@sap-cloud-sdk/http-client, v4) adds destination handling, token caching and CSRF on top of the same calls. executeHttpRequest(destination, requestConfig) takes a destination ({ url, username, password } or a BTP destination name) and { method, url, headers, data }:
import { executeHttpRequest } from "@sap-cloud-sdk/http-client";
const res = await executeHttpRequest(
{ url: process.env.SAP_HOST!, username: process.env.SAP_USER!, password: process.env.SAP_PASSWORD! },
{ method: "GET", url: "/sap/opu/odata/sap/API_BUSINESS_PARTNER/A_BusinessPartner?$top=5&$select=BusinessPartner" },
);
The pregenerated @sap/cloud-sdk-vdm-* packages are deprecated; generate a typed client with @sap-cloud-sdk/generator instead.
SAP Business One Service Layer: log in with company database, user and password, then send the session cookies from the login response on every call, and log out when done.
const B1_URL = process.env.B1_SERVICE_LAYER_URL!; // e.g. https://b1-prod.acme.example:50000/b1s/v1
async function b1Login(): Promise<string> {
const res = await fetch(`${B1_URL}/Login`, {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ CompanyDB: process.env.B1_COMPANY_DB, UserName: process.env.B1_USER, Password: process.env.B1_PASSWORD }),
});
if (!res.ok) throw new Error(`B1 login failed: ${res.status}`);
return res.headers.getSetCookie().map((c) => c.split(";")[0]).join("; ");
}
async function b1Api(method: string, path: string, session: string, body?: unknown) {
const res = await fetch(`${B1_URL}${path}`, {
method, headers: { "Content-Type": "application/json", Cookie: session },
body: body ? JSON.stringify(body) : undefined,
});
if (!res.ok) throw new Error(`B1 ${res.status}: ${await r
Установить sap в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sap?
Connect to SAP S/4HANA (OData APIs), SAP Business One (Service Layer) and build SAP CAP applications on SAP BTP with Node.js. Use when a user asks to read or create business partners, sales orders or purchase orders in S/4HANA, automate Business One documents, scaffold a CAP service, or sync SAP with Shopify or another external system. Covers OAuth and CSRF handling, the SAP Cloud SDK HTTP client, and polling and webhook integration patterns.
Как установить скилл sap?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sap запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic