# SAP ERP

With SAP connected, the agent greets a known caller by name, finds their customer record by phone, ΑΦΜ, customer number or name, searches your materials, reads their recent sales orders and the status of a specific order, and can post a new sales order while the caller is on the line. One connector covers both **SAP S/4HANA** (OData APIs, Cloud or on-prem) and **SAP Business One** (Service Layer).

Open **Integrations - Catalogue - SAP ERP - Connect**. One connection is shared by the whole company; every agent that turns the SAP tool on uses it.

  <ShotPlaceholder
    src="/assets/integrations/sap.png"
    name="sap-connect"
    alt="Connect SAP ERP dialog with SAP product switch, Cloud URL / Tunnel switch and credentials"
    capture="Connect SAP ERP dialog."
  />

## What you need before you start

Ask your SAP administrator or SAP partner for the following, depending on your product.

**S/4HANA Cloud**

- A communication arrangement that exposes the business partner, product and sales order OData APIs (API_BUSINESS_PARTNER, API_PRODUCT_SRV, API_SALES_ORDER_SRV).
- Either the communication user and password from that arrangement, or an OAuth 2.0 client-credentials set: client ID, client secret and token URL.
- The API host of your tenant.

**S/4HANA on-prem (or ECC with Gateway)**

- The same three OData services activated on the Gateway.
- A service user with OData authorisations, and the SAP client number (for example 100).

**Business One**

- The Service Layer address (usually on port 50000).
- The company database name (CompanyDB).
- A B1 user with rights to Business Partners, Items and Sales Orders on that company.

**Network.** If SAP answers on a public HTTPS address, use **Cloud URL**. If it only runs inside your office network, it is reached through a Voice Logica tunnel: a small relay service installed on a machine in your network (Windows or Linux installer) that forwards requests to the SAP host and port. Ask Voice Logica support to set the tunnel up; once it is active it appears in the **Tunnel** list of the dialog.

## What you enter

- **SAP product** (required) — **S/4HANA (OData)** or **Business One (Service Layer)**. The fields below change with this choice.
- **Cloud URL / Tunnel** (required) — Pick how Voice Logica reaches SAP.
- **Base URL** (required) — Cloud only. The S/4HANA API host or on-prem Gateway host, or the Business One Service Layer root. No trailing slash.
- **Tunnel** (required) — Tunnel only. The active tunnel that points at your SAP server.
- **Company database (CompanyDB)** (required) — Business One only. The company schema name as it appears in B1.
- **Authentication** — S/4HANA only. **Basic (communication user)** or **OAuth2 (client credentials)**. Business One always uses user and password.
- **Username / Password** (required) — Basic authentication and Business One. The communication, service or B1 user described above.
- **Client ID / Client secret / Token URL** (required) — S/4HANA with OAuth2 only. All three come from the communication arrangement.
- **SAP client (optional)** — S/4HANA on-prem only. Leave empty on S/4HANA Cloud.

Under **Advanced settings**, all optional:

- **Language (optional)** — S/4HANA: language of product descriptions and of remarks on orders the agent creates.
- **Phone country code** — `30` — Used to match the caller's number to the phones stored in SAP.
- **Trust self-signed TLS certificate (on-prem HTTPS)** — Turn on only for an on-prem server with its own certificate.
- **Sales order type / Sales organization / Distribution channel / Division** — S/4HANA only. The organisational data stamped on orders the agent creates. Sales organization, distribution channel and division are needed before the agent can create orders.
- **Price list number (optional)** — Business One only. The price list used when the agent quotes prices.

## First setup

1. **Integrations - Catalogue - SAP ERP - Connect**

   Pick the SAP product, then **Cloud URL** or **Tunnel**, and fill the credentials for that combination. Fill the sales order defaults under **Advanced settings** if the agent will take orders.

2. **Test connection**

   Voice Logica signs in and reads one customer. Fix any error before you continue.

3. **Connect**

   The connection is saved and the first sync of customers and products starts. After that, SAP is re-synced every hour.

4. **My Agents - your agent - Skills - Tools & Workflows**

   Turn **SAP ERP** on. Under **Operations** keep **Identify caller by phone** and add the ones you need. Leave **Auto-identify caller on connect** on so the caller is looked up before the agent speaks. Set **Max sales order value** and **Max sales order lines** if you enable **Create sales order**.

5. **Save** the agent.

6. **Prove it**

   Call the agent from a phone number stored on an SAP customer. The agent should greet you by the customer name. Ask "What is the status of my last order?" and you should hear the most recent sales order with its date and status. Then ask for a product by name and check the agent finds it.

## What the agent can do

| Job | Operations |
|---|---|
| Know who is calling | Identify caller by phone; look up customer by ΑΦΜ, by customer number (CardCode) or by name |
| Answer product questions | Search products by name, code or barcode |
| Orders | List the customer's recent sales orders; read one order with lines, quantities and delivery status |
| Account | Read the customer's open balance (Business One; S/4HANA does not return a balance through this connection) |
| Take an order | Create sales order |

**Pre-fetch recent orders on call start** loads the identified caller's latest orders before the agent speaks.

**Create sales order** writes to SAP. It only runs when you enable it under **Operations**. On S/4HANA it also needs the sales organization, distribution channel and division set in the connection. Orders above **Max sales order value** or with more lines than **Max sales order lines** are rejected and the agent tells the caller.

## Troubleshooting

**Test connection fails**

The error shows the HTTP status SAP returned.

- **401 or 403**: wrong user or password, or the user lacks authorisation for the OData services (S/4HANA) or for Business Partners (Business One).
- **OAuth2 token request failed**: check the client ID, secret and token URL against the communication arrangement.
- **Business One login failed**: check the CompanyDB name and the B1 user.
- Timeout or connection refused: SAP is not reachable from the internet. Use a tunnel, or confirm the tunnel shows as active.

**The agent does not recognise a caller who is in SAP**

Caller ID uses the synced customer list, refreshed every hour. Check that the caller's number is stored on the customer in SAP, that **Phone country code** matches your country, and that **Identify caller by phone** is selected on the agent. A customer added a few minutes ago appears after the next sync.

**The agent cannot create a sales order**

On S/4HANA, fill **Sales organization**, **Distribution channel** and **Division** in the connection (reconnect to change them). Check that **Create sales order** is selected on the agent and that the order is within the max value and max lines you set. The agent resolves products through search first, so the material must exist in the synced product list.

## Next Steps

[Get an integration working](https://docs.voicelogica.ai/integrations/) - company connection, then the agent tool.  
[Tools & Workflows](https://docs.voicelogica.ai/agent-configuration/built-in-tools/) - where the SAP tool is turned on.  
[Soft1](https://docs.voicelogica.ai/integrations/erp/soft1/) · [Entersoft ONE](https://docs.voicelogica.ai/integrations/erp/entersoft-one/) · [Odoo](https://docs.voicelogica.ai/integrations/erp/odoo/) - other ERP connections.
