> ## Documentation Index
> Fetch the complete documentation index at: https://explore.airia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SAP

> Manage SAP S/4HANA business partners, materials, purchase orders, and sales orders from inside an agent workflow.

SAP actions let an agent work with SAP S/4HANA data directly in a flow. An agent can create, update, read, list, and delete business partners, read materials, and manage purchase orders and sales orders, then pass the results to later steps.

## Supported actions

| Group                | Actions                              |
| -------------------- | ------------------------------------ |
| **Business partner** | Create, Update, Get, Get All, Delete |
| **Material**         | Get, Get All                         |
| **Purchase order**   | Create, Update, Get, Get All         |
| **Sales order**      | Create, Update, Get, Get All         |

## Prerequisites

<AccordionGroup>
  <Accordion title="Create an SAP credential" icon="key">
    Store your SAP API key as an **SAP** credential in [Credential Management](/admin-hub/account_settings/credential-management). Select that credential on every SAP action.
  </Accordion>
</AccordionGroup>

## How to use these actions

* **Every action needs your tenant Base URL.** Supply the **Base URL** of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`, on every action.
* **Map text inputs from earlier steps.** Inputs such as identifiers and names accept a value mapped from a previous step.
* **Paging numbers take fixed values.** The **Top** and **Skip** numbers are entered as fixed values.
* **Get All actions accept OData query options.** Use **Filter** to narrow results, **Top** to limit the number returned, and **Skip** to page through results.
* **Materials are read only.** You can read materials with **Get** and **Get All**.
* **Choose names by partner type.** For a person business partner, provide a first and last name. For an organization, provide the organization name.

## Actions

### Business partner

#### SAP Business Partner Create

Creates a new business partner.

| Input                         | Required | Description                                                                     |
| ----------------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**                  | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Business Partner Category** | Yes      | The partner category: `1` for an organization, `2` for a person.                |
| **First Name**                | No       | The first name. Used for a person.                                              |
| **Last Name**                 | No       | The last name. Used for a person.                                               |
| **Organization Name**         | No       | The organization name. Used for an organization.                                |
| **Business Partner Grouping** | No       | The grouping code for number range assignment.                                  |

#### SAP Business Partner Update

Updates an existing business partner.

| Input                         | Required | Description                                                                     |
| ----------------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**                  | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Business Partner ID**       | Yes      | The unique identifier of the business partner to update.                        |
| **Search Term 1**             | No       | A search term for the business partner.                                         |
| **Business Partner Grouping** | No       | The grouping code for number range assignment.                                  |

#### SAP Business Partner Get

Retrieves a business partner by ID.

| Input                   | Required | Description                                                                     |
| ----------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**            | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Business Partner ID** | Yes      | The unique identifier of the business partner to retrieve.                      |

#### SAP Business Partner Get All

Lists business partners.

| Input        | Required | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL** | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Top**      | No       | Maximum number of records to return. A fixed number.                            |
| **Skip**     | No       | Number of records to skip for paging. A fixed number.                           |
| **Filter**   | No       | An OData filter expression to narrow results.                                   |

#### SAP Business Partner Delete

Deletes a business partner.

| Input                   | Required | Description                                                                     |
| ----------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**            | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Business Partner ID** | Yes      | The unique identifier of the business partner to delete.                        |

### Material

#### SAP Material Get

Retrieves a material by ID.

| Input           | Required | Description                                                                     |
| --------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**    | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Material ID** | Yes      | The product or material number.                                                 |

#### SAP Material Get All

Lists materials.

| Input        | Required | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL** | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Top**      | No       | Maximum number of records to return. A fixed number.                            |
| **Skip**     | No       | Number of records to skip for paging. A fixed number.                           |
| **Filter**   | No       | An OData filter expression to narrow results.                                   |

### Purchase order

#### SAP Purchase Order Create

Creates a new purchase order.

| Input                       | Required | Description                                                                     |
| --------------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**                | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Purchase Order Type**     | Yes      | The order type, such as `NB` for a standard order.                              |
| **Purchasing Organization** | Yes      | The purchasing organization.                                                    |
| **Purchasing Group**        | Yes      | The purchasing group.                                                           |
| **Company Code**            | Yes      | The company code.                                                               |
| **Supplier**                | Yes      | The supplier or vendor number.                                                  |

#### SAP Purchase Order Update

Updates an existing purchase order.

| Input                 | Required | Description                                                                     |
| --------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**          | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Purchase Order ID** | Yes      | The unique identifier of the purchase order to update.                          |
| **Payment Terms**     | No       | The payment terms for the order.                                                |

#### SAP Purchase Order Get

Retrieves a purchase order by ID.

| Input                 | Required | Description                                                                     |
| --------------------- | -------- | ------------------------------------------------------------------------------- |
| **Base URL**          | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Purchase Order ID** | Yes      | The unique identifier of the purchase order to retrieve.                        |

#### SAP Purchase Order Get All

Lists purchase orders.

| Input        | Required | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL** | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Top**      | No       | Maximum number of records to return. A fixed number.                            |
| **Skip**     | No       | Number of records to skip for paging. A fixed number.                           |
| **Filter**   | No       | An OData filter expression to narrow results.                                   |

### Sales order

#### SAP Sales Order Create

Creates a new sales order.

| Input                          | Required | Description                                                                     |
| ------------------------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL**                   | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Sales Order Type**           | Yes      | The order type, such as `OR` for a standard order.                              |
| **Sales Organization**         | Yes      | The sales organization.                                                         |
| **Distribution Channel**       | Yes      | The distribution channel.                                                       |
| **Organization Division**      | Yes      | The organization division.                                                      |
| **Sold To Party**              | Yes      | The sold to party number.                                                       |
| **Purchase Order By Customer** | No       | The customer purchase order reference.                                          |

#### SAP Sales Order Update

Updates an existing sales order.

| Input                          | Required | Description                                                                     |
| ------------------------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL**                   | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Sales Order ID**             | Yes      | The unique identifier of the sales order to update.                             |
| **Purchase Order By Customer** | No       | The customer purchase order reference.                                          |

#### SAP Sales Order Get

Retrieves a sales order by ID.

| Input              | Required | Description                                                                     |
| ------------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL**       | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Sales Order ID** | Yes      | The unique identifier of the sales order to retrieve.                           |

#### SAP Sales Order Get All

Lists sales orders.

| Input        | Required | Description                                                                     |
| ------------ | -------- | ------------------------------------------------------------------------------- |
| **Base URL** | Yes      | The base URL of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. |
| **Top**      | No       | Maximum number of records to return. A fixed number.                            |
| **Skip**     | No       | Number of records to skip for paging. A fixed number.                           |
| **Filter**   | No       | An OData filter expression to narrow results.                                   |

## Example

An agent that creates a sales order for a known customer:

<Steps>
  <Step title="Find the customer">
    A **SAP Business Partner Get All** action with a **Filter** locates the customer so a model step can confirm the **Sold To Party** number.
  </Step>

  <Step title="Create the sales order">
    A **SAP Sales Order Create** action sets the **Base URL**, **Sales Order Type**, **Sales Organization**, **Distribution Channel**, **Organization Division**, and the matched **Sold To Party**.
  </Step>

  <Step title="Confirm">
    A model step summarizes the created sales order, including its returned identifier, for the activity log.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Authentication failed" icon="lock">
    Confirm the stored API key is valid and has not been rolled, and that the **Base URL** points to the same tenant the key belongs to.
  </Accordion>

  <Accordion title="Invalid or missing Base URL" icon="link-slash">
    Every SAP action needs the **Base URL** of your S/4HANA tenant, such as `https://tenant.s4hana.cloud.sap`. Confirm the value has no trailing path and is reachable.
  </Accordion>

  <Accordion title="Entity not found" icon="circle-question">
    The **Business Partner ID**, **Material ID**, **Purchase Order ID**, or **Sales Order ID** does not exist in this tenant. Use a **Get All** action with a **Filter** to discover valid IDs.
  </Accordion>

  <Accordion title="Missing required fields on create" icon="triangle-exclamation">
    Create actions require their organizational fields. For a business partner, set **Business Partner Category** and the matching name fields. For orders, set the order type and organization fields.
  </Accordion>
</AccordionGroup>

For issues common to every vendor, see the [Actions overview](/building-and-deploying-agents/agent-basics/actions/overview#troubleshooting).
