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

# SAP S/4HANA

> Integration details and setup guide for the SAP S/4HANA connector in Alloy Automation.

## Pre-Built Tooling

| Category                            | Details                                    |
| ----------------------------------- | ------------------------------------------ |
| **Authentication**                  | Basic Authentication (Username & Password) |
| **Two-Way Sync**                    | No                                         |
| **Events Supported**                | No                                         |
| **Realtime**                        | No (Polling)                               |
| **Supports Rate Limiting**          | Yes                                        |
| **Authentication Scopes Supported** | N/A (Basic Auth)                           |

***

## Objects Supported

Alloy Automation supports interacting with **SAP S/4HANA** via OData services. The connector provides access to:

* **Custom OData Services** - Access any exposed OData endpoint in your SAP S/4HANA instance
* **Standard SAP Objects** - Accounts, Sales Orders, Purchase Orders, Invoices, Materials, etc.
* **Custom Actions** - Execute custom OData operations defined in your SAP system

***

## Set Up Guide

### Trial Access

| Question                                           | Answer                                                                                                                                   |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Offers free trial?**                             | Yes. SAP offers a trial system through SAP Cloud Appliance Library or partner evaluation systems. [Access SAP CAL](https://cal.sap.com/) |
| **Requires paid sandbox**                          | No, but production systems require SAP licensing.                                                                                        |
| **Requires partnership to obtain authentication?** | No. However, access to a SAP S/4HANA instance (trial, dev, or production) is required.                                                   |

***

### Authentication (Basic Auth)

SAP S/4HANA uses Basic Authentication with a communication user for API access.

<step>
  ## Step 1: Access SAP S/4HANA Trial

  1. Visit the **SAP Cloud Appliance Library** ([https://cal.sap.com/](https://cal.sap.com/))
  2. Search for "SAP S/4HANA" trial systems
  3. Create a trial instance (requires SAP Universal ID)
  4. Note your system's hostname, port, and HTTPS endpoint
</step>

<step>
  ## Step 2: Create a Communication User

  1. Log into your SAP S/4HANA system via SAP GUI or SAP Fiori
  2. Navigate to **Transaction SU01** (User Maintenance)
  3. Create a new communication user with type "System" or "Communication"
  4. Assign necessary authorizations for OData service access
  5. Set a secure password for the user
</step>

<step>
  ## Step 3: Configure OData Services

  1. Navigate to **Transaction /IWFND/MAINT\_SERVICE** (Activate and Maintain Services)
  2. Activate the OData services you want to expose
  3. Test the service endpoint using **/IWFND/GW\_CLIENT**
  4. Note the service URL path (e.g., `/sap/opu/odata/sap/SERVICE_NAME`)
</step>

<step>
  ## Step 4: Configure Alloy Automation

  1. In Alloy Automation, provide your SAP S/4HANA credentials:
     * **SAP Username**: Your communication user ID
     * **SAP Password**: The communication user password
     * **Hostname**: Your SAP S/4HANA hostname (e.g., `my-s4hana-system.example.com`)
     * **Port**: HTTPS port (typically `443` or `44300` for trial systems)
  2. Test the connection by listing available OData services
</step>

***

## Use Cases

### 1) Real-time order synchronization

Sync sales orders between SAP S/4HANA and e-commerce platforms, keeping order status, pricing, and inventory levels updated across systems in real-time.

### 2) Master data management

Automatically create and update customer master data, material master records, and vendor information between SAP S/4HANA and CRM or external data sources.

### 3) Financial data integration

Extract financial documents (invoices, payment records, general ledger entries) from SAP S/4HANA for reporting, analytics, or integration with third-party financial systems.

### 4) Procurement automation

Automate purchase requisition creation, purchase order processing, and goods receipt posting by integrating SAP S/4HANA with procurement platforms and supplier portals.

### 5) Inventory and warehouse management

Connect SAP S/4HANA with warehouse management systems to synchronize stock levels, trigger replenishment workflows, and track inventory movements across locations.

***

## API Gotchas

* **OData Service Activation Required:** Not all SAP objects are exposed via OData by default. You must explicitly activate OData services in transaction /IWFND/MAINT\_SERVICE before they can be accessed via the API.

* **Authorization Objects:** SAP uses granular authorization objects (e.g., S\_SERVICE for OData services). Ensure your communication user has proper authorizations assigned, or API calls will fail with 403 Forbidden errors.

* **Complex Data Types:** SAP S/4HANA OData services often return deeply nested XML or JSON structures. Field names may be in German or use SAP-specific abbreviations (e.g., BUKRS for company code, VBELN for sales document number).

* **CSRF Token Requirement:** For POST, PUT, PATCH, and DELETE operations, SAP S/4HANA requires an X-CSRF-Token. You must first make a GET request with `x-csrf-token: fetch` header to obtain a token, then include it in subsequent write operations.

* **Connection Limits:** SAP systems have connection pooling limits. If you're running high-volume integrations, monitor RFC connection usage and work with your SAP Basis team to adjust connection settings if needed.

> For questions or troubleshooting, contact **[support@runalloy.com](mailto:support@runalloy.com)**.
