[[{“value”:”
- A CAP service that proxies the S/4HANA `API_OUTBOUND_DELIVERY_SRV` OData v2 API
- An MCP endpoint consumable by any MCP-compatible AI client
- A deployed application on SAP BTP Cloud Foundry
- SAP BTP account with Cloud Foundry environment
- S/4HANA Cloud system with access to the Outbound Delivery API
- SAP CAP (`@sap/cds`) installed globally. Refer to the CAP initial setup guide
- Node.js 20+
- Cloud Foundry CLI (`cf`)
cds init capmcps4 –nodejs
cd capmcps4
code .
cds import <path-to-edmx-file> –as cds –out srv/external/API_OUTBOUND_DELIVERY_SRV_0002.cds
“cds”: {
“requires”: {
“API_OUTBOUND_DELIVERY_SRV_0002”: {
“kind”: “odata-v2”,
“model”: “srv/external/API_OUTBOUND_DELIVERY_SRV_0002”
}
}
}
“cds”: {
“mcp”: {
“per_action_tool”: true
},
“requires”: {
“API_OUTBOUND_DELIVERY_SRV_0002”: {
“kind”: “odata-v2”,
“model”: “srv/external/API_OUTBOUND_DELIVERY_SRV_0002”,
“[hybrid]”: {
“csrf”: true,
“csrfInBatch”: true,
“credentials”: {
“url”: “https://<S4-instance>-api.s4hana.ondemand.com/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV;v=0002”,
“authentication”: “BasicAuthentication”,
“username”: “<S4-communication-user>”,
“password”: “<S4-communication-password>”
}
},
“[production]”: {
“credentials”: {
“destination”: “<S4-destination-name>”,
“path”: “/sap/opu/odata/sap/API_OUTBOUND_DELIVERY_SRV;v=0002”
}
}
}
}
}
using {API_OUTBOUND_DELIVERY_SRV_0002 as s4h} from ‘./external/API_OUTBOUND_DELIVERY_SRV_0002’;
@title : ‘Outbound Delivery Service’
@description: ‘Manages outbound delivery headers and items from SAP S/4HANA.’
service dnsservices {
@title : ‘Delivery Document’
@description: ‘Outbound delivery header from S/4HANA. Contains shipping details, partner data, dates, and overall status.’
entity DeliveryDocument as projection on s4h.A_OutbDeliveryHeader;
@title : ‘Delivery Document Item’
@description: ‘Line items of an outbound delivery. Each item holds material, quantity, plant, and storage details.’
entity DeliveryDocumentItem as projection on s4h.A_OutbDeliveryItem;
type DeliveryItemInput {
ReferenceSDDocument : String;
ReferenceSDDocumentItem: String;
}
action createDelivery(
ShippingPoint : String;
items : many DeliveryItemInput
) returns DeliveryDocument;
}
annotate dnsservices with @protocol: [
‘odata-v4’,
‘mcp’
];
const cds = require(“@sap/cds”);
class Dnsrv extends cds.ApplicationService {
async init() {
const s4h = await cds.connect.to(“API_OUTBOUND_DELIVERY_SRV_0002”);
this.on(“createDelivery”, async (req) => {
const { ShippingPoint, items = [] } = req.data;
if (!ShippingPoint) return req.error(400, “ShippingPoint is required”);
return s4h.send({
method: “POST”,
path: “/A_OutbDeliveryHeader”,
data: {
ShippingPoint,
to_DeliveryDocumentItem: {
results: items.map((item) => ({
ReferenceSDDocument: item.ReferenceSDDocument,
ReferenceSDDocumentItem: item.ReferenceSDDocumentItem,
})),
},
},
});
});
this.on(“READ”, [“DeliveryDocument”, “DeliveryDocumentItem”], (req) => s4h.run(req.query));
this.on(“CREATE”, [“DeliveryDocument”, “DeliveryDocumentItem”], (req) => s4h.run(req.query));
this.on(“UPDATE”, [“DeliveryDocument”, “DeliveryDocumentItem”], (req) => s4h.run(req.query));
this.on(“DELETE”, [“DeliveryDocument”, “DeliveryDocumentItem”], (req) => s4h.run(req.query));
return super.init();
}
}
module.exports = { dnsservices: Dnsrv };
npm add @cap-js/mcp
cds add xsuaa
cds add mta
npm i
cds watch –profile hybrid
@server=http://localhost:4004
@username=alice
@password=
# ─── List available MCP tools ────────────────────────────────────────────────
### MCP – list tools
POST {{server}}/mcp/dnsservices
Content-Type: application/json
Accept: application/json, text/event-stream
{
“jsonrpc”: “2.0”,
“id”: 1,
“method”: “tools/list”
}
# ─── Describe service schema ─────────────────────────────────────────────────
### MCP – describe service
POST {{server}}/mcp/dnsservices
Content-Type: application/json
Accept: application/json, text/event-stream
{
“jsonrpc”: “2.0”,
“id”: 2,
“method”: “tools/call”,
“params”: {
“name”: “describe”,
“arguments”: {}
}
}
# ─── Query delivery documents ─────────────────────────────────────────────────
### MCP – query DeliveryDocument
POST {{server}}/mcp/dnsservices
Content-Type: application/json
Accept: application/json, text/event-stream
{
“jsonrpc”: “2.0”,
“id”: 3,
“method”: “tools/call”,
“params”: {
“name”: “query”,
“arguments”: {
“entity”: “DeliveryDocument”,
“limit”: 5
}
}
}
### MCP – query DeliveryDocumentItem
POST {{server}}/mcp/dnsservices
Content-Type: application/json
Accept: application/json, text/event-stream
{
“jsonrpc”: “2.0”,
“id”: 4,
“method”: “tools/call”,
“params”: {
“name”: “query”,
“arguments”: {
“entity”: “DeliveryDocumentItem”,
“limit”: 5
}
}
}
# ─── Create a delivery ────────────────────────────────────────────────────────
### MCP – action createDelivery
POST {{server}}/mcp/dnsservices
Content-Type: application/json
Accept: application/json, text/event-stream
{
“jsonrpc”: “2.0”,
“id”: 5,
“method”: “tools/call”,
“params”: {
“name”: “createDelivery”,
“arguments”: {
“ShippingPoint”: “1710”,
“items”: [
{
“ReferenceSDDocument”: “533916”,
“ReferenceSDDocumentItem”: “000010”
},
{
“ReferenceSDDocument”: “533917”,
“ReferenceSDDocumentItem”: “000010”
}
]
}
}
}
cf login -a <cloud-foundry-api-url> –sso
npm i
cds up
“}]]
Read More Technology Blog Posts by SAP articles
#abap