# SAP S/4HANA MCP

> The SAP S/4HANA MCP Server connects your AI agent directly to core Enterprise Resource Planning functions. Manage vendor records, generate purchase orders, check real-time inventory stock levels across plants, and post financial journal entries—all through natural language conversation. It gives you transactional control over the system without needing a GUI.

## Overview
- **Category:** industry-titans
- **Price:** Free
- **Tags:** purchase-orders, master-data, inventory-management, financial-postings, business-partners, enterprise-resource-planning

## Description

You're connecting your AI agent right into SAP S/4HANA, so you don't have to mess with transaction codes or navigate complex menus. You talk naturally, and it handles the transactions in the core ERP system.

Managing Vendor and Customer Records: Need to add a new supplier? Use `create_business_partner` to generate an entire vendor or customer master record. If you know their ID number, `get_business_partner` pulls up all of that specific data for you instantly. You can also run through the existing contacts using `list_business_partners`, letting your agent filter those records by type—whether they're a person or an organization.

Processing Purchase Orders: When it comes to buying stuff, you can generate and submit structured purchase orders with all their specified line items using `create_purchase_order`. Need to check what else is going on? You'll use `list_purchase_orders` to pull up a list of POs, letting your agent filter that list by specific vendors or current status. 

Sales and Shipping Status: For the other side of the ledger—sales—your agent runs `list_sales_orders`, giving you a clear view of those orders and exactly what their delivery or billing status is.

Inventory Management: Tracking stock should be easy. Run `get_material_stock` to get real-time material availability across every single storage location or plant defined in the system. This tells you the exact count, period.

Financial Accounting: For the money stuff, your agent uses `get_gl_balances` to pull current and historical balance data directly from General Ledger accounts. If you're posting a new journal entry, it handles that too.

Custom Reports and Data Queries: Don't see what you need in the standard tools? No sweat. Use `query_odata`. This lets your agent execute any exposed OData v4 service to run custom data reports across modules not covered by the basic functions, giving you deep access into specific production planning metrics or niche operational details.

It’s transactional control over the whole system, all through conversation. You'll get actionable results whether you're setting up a new partner record, checking if there’s enough material on hand to fulfill an order, posting a journal entry, or running a deep dive report across several modules.

## Tools

### create_business_partner
Creates a new vendor or customer record in the SAP system.

### create_purchase_order
Generates and submits a structured purchase order with specified line items.

### get_business_partner
Retrieves all details for one specific business partner using its ID number.

### get_gl_balances
Pulls current balances and historical data from the General Ledger accounts.

### get_material_stock
Returns the available quantity of a specific material across all defined storage locations.

### list_business_partners
Searches and returns lists of business partners, allowing filtering by type (person/organization).

### list_purchase_orders
Lists multiple purchase orders, supporting filters like vendor or status.

### list_sales_orders
Retrieves a list of sales orders and their current delivery or billing status.

### query_odata
Executes any exposed OData v4 service for custom data reports across the system.

## Prompt Examples

**Prompt:** 
```
Show me all pending purchase orders for plant 1000 above €50,000.
```

**Response:** 
```
Found 7 pending POs for Plant 1000 above €50K: 1. PO 4500012345 — 'Raw Materials Q2' (€125,000, Supplier: ACME GmbH), 2. PO 4500012350 — 'Server Equipment' (€89,500, Supplier: TechCorp), and 5 more. Total pending value: €487,230. Would you like to approve or view details?
```

**Prompt:** 
```
What's the current stock level for material MAT-2024-A across all plants?
```

**Response:** 
```
Material MAT-2024-A stock levels: Plant 1000 (Berlin) — 2,450 units, Plant 2000 (Shanghai) — 1,800 units, Plant 3000 (São Paulo) — 920 units. Total available: 5,170 units. Safety stock threshold is 1,000/plant — São Paulo is below threshold. Want me to create a purchase requisition?
```

**Prompt:** 
```
Create a business partner record for 'NovaTech Solutions' as a supplier.
```

**Response:** 
```
Business Partner BP-0010045678 ('NovaTech Solutions') created successfully as a Supplier. Category: Organization, Role: Vendor. Would you like me to add bank details, purchasing organization assignments, or a contact person?
```

## Capabilities

### Manage Vendor and Customer Records
Create, retrieve, or list all business partner master data (customers, suppliers) using specific IDs or filters.

### Process Purchase Orders
Generate new purchase orders with line items for a vendor or check the status and history of existing POs.

### Track Inventory Levels
Get real-time material stock availability across specific plants or storage locations.

### Perform Financial Accounting
Query General Ledger account balances and submit journal entries for financial postings.

### Run Custom System Queries
Execute custom OData v4 queries to retrieve data from modules not covered by standard tools (e.g., specific production planning metrics).

## Use Cases

### The Month-End Close:
A Financial Analyst needs to reconcile cost centers. Instead of running three different reports in SAP FI, they ask their agent to check G/L account balances using `get_gl_balances`. The system pulls the raw balance data and presents it, allowing them to proceed immediately with journal entries.

### Urgent Vendor Onboarding:
A Procurement Specialist gets a quote from a new supplier. They use `create_business_partner` to add the vendor record first, then use that resulting BP ID to call `create_purchase_order`, completing both setup and ordering in one chat session.

### Addressing Stock Shortfalls:
A Supply Chain Planner notices a potential bottleneck. They ask for the stock level of 'MAT-XYZ' using `get_material_stock`. The system confirms low stock at Plant 2000, triggering a follow-up action to list pending POs that need to be checked.

### Auditing Complex Data:
An external consultant needs to check the total sales order value for Q1 across three regions. They don't have a standard report, so they use `query_odata` with specific parameters (service path and filters) to pull the exact data set required.

## Benefits

- Instantly generate purchase orders. Instead of filling out 10 screens, you simply ask the agent to `create_purchase_order` with the necessary details, and it handles the entire submission process.
- Stop spreadsheet cross-referencing inventory counts. Use `get_material_stock` to get total available units by plant instantly, giving you immediate visibility into stock levels.
- Simplify financial reporting. Get a snapshot of G/L account balances using `get_gl_balances`. This eliminates the need to navigate multiple accounting reports just to check an ending balance.
- Master data management is faster than ever. You can onboard new vendors or clients by calling `create_business_partner`, keeping your partner records current without touching SAP GUI.
- Handle custom reporting with `query_odata`. If a standard report doesn't exist, you provide the service path and let your agent pull exactly the data you need.

## How It Works

The bottom line is: You talk to your AI client, the client talks to SAP via these tools, and you get actionable data back—no manual navigation needed.

1. Subscribe to this server and provide your SAP S/4HANA Communication User credentials and instance URL.
2. Your AI client connects, authenticating against the exposed API endpoints within your system.
3. You ask a question (e.g., 'What's stock for MAT-123?'), and the agent calls the correct tool (`get_material_stock`), processes the result, and gives you a direct answer.

## Frequently Asked Questions

**How do I use `create_purchase_order`?**
You must provide a structured JSON payload including the CompanyCode, PurchaseOrderType, and all line items within the required array. The agent can guide you on the necessary fields.

**Can I check stock using `get_material_stock`?**
Yes. You provide the material ID and specify which plants or storage locations you want to check. It returns available units for each location instantly.

**What is the difference between `list_business_partners` and `get_business_partner`?**
`list_business_partners` searches a group of records, allowing you to filter by criteria like 'Organization' or status. `get_business_partner`, however, requires an exact ID to retrieve a single, specific record.

**Is `query_odata` for general reporting?**
That’s right. It runs any exposed OData v4 service path on your system. Use this when the standard tools don't cover a unique data pull you need for an audit or report.

**How do I post financial entries with `get_gl_balances`?**
While `get_gl_balances` retrieves current balances, the full posting capability requires providing detailed journal entry parameters—accounts, debit/credit amounts, and cost centers.

**How do I filter results when listing purchase orders using `list_purchase_orders`?**
You use OData `$filter` syntax for precise filtering. You can restrict Purchase Orders by status, supplier ID, or date range in one call. This keeps your data set small and focused.

**What permissions are required to successfully run `create_business_partner`?**
The connected user must have write access (Create/Update) for Business Partner master data. If the role is read-only, the call will fail with an authorization error code.

**Can I retrieve associated details using `query_odata`?**
Yes, use the `$expand` operator to traverse related entities. This lets you pull associated data—like line items for a PO or addresses for a BP—in one single query execution.

**What authentication does SAP S/4HANA require?**
SAP S/4HANA uses Communication Arrangements with a dedicated Communication User. You create a technical user in the Fiori Launchpad, assign it to a Communication System, and link it to the appropriate Communication Scenario (e.g. SAP_COM_0008 for Business Partners).

**Can I create purchase orders through the agent?**
Yes. The `create_purchase_order` tool posts to the A_PurchaseOrder OData endpoint. Provide the supplier, purchasing organization, plant, material, quantity, and price — the agent returns the PO number on success.

**Does it support querying custom OData services?**
Absolutely. The `query_odata` tool executes GET requests against any OData v4 service exposed via your Communication Arrangement, including custom CDS views. Full $filter, $expand, and $select support is included.

**Can I check stock levels across multiple plants?**
Yes. The `get_material_stock` tool queries the A_MaterialStock OData service, returning current stock quantities by plant and storage location. You can filter by material number, plant, or storage location.