SAP S/4HANA Connector

Integrate with SAP for purchase orders, invoices, and inventory management

SAP S/4HANA Connector

Connect your workflows to SAP S/4HANA and automate enterprise resource planning. Manage purchase orders, sales orders, inventory, and financial transactions—all from DeepChain.

Overview

The SAP connector provides 8 operations for managing SAP business processes. Whether you're automating procurement, managing inventory, or processing financial documents, this connector integrates with your SAP ecosystem.

Authentication

SAP supports two authentication methods:

Option 1: OAuth 2.0 (Recommended)

Secure, delegated access:

auth_type: oauth2
token_url: "https://your-sap-instance/oauth/token"
client_id: "your-client-id"
client_secret: "your-client-secret"

How to set it up:

  1. In SAP, configure OAuth2 server
  2. Register DeepChain as an OAuth client
  3. Get your Client ID and Client Secret
  4. Set redirect URI: https://yourapp.deepchain.dev/oauth/callback

Option 2: Basic Auth

Username/password authentication (for development):

auth_type: basic
host: "your-sap-instance.s4hana.cloud.sap"
username: "api_user"
password: "your-password"

Available Operations

Operation What It Does
getSalesOrder Fetch sales order by ID
createSalesOrder Create new sales order
getPurchaseOrder Fetch purchase order
createPurchaseOrder Create new PO
getMaterial Get material master data
getBusinessPartner Get supplier/customer info
createBusinessPartner Create new business partner
getInventory Get inventory levels

Practical Workflow Examples

Example 1: Create Sales Order

Generate sales order from order request:

- id: create_sales_order
  type: sap_connector
  config:
    operation: createSalesOrder
    SalesOrderType: "OR"              # Order
    SalesOrganization: "1000"         # Your org
    DistributionChannel: "10"         # Direct sales
    Division: "00"
    SoldToParty: "{{ input.customer_id }}"
    ShipToParty: "{{ input.ship_to }}"
    to_Item:
      - Material: "{{ input.material_id }}"
        RequestedQuantity: "{{ input.qty }}"
        OrderQuantityUnit: "EA"       # Each
        NetPrice: "{{ input.unit_price }}"

Example 2: Create Purchase Order

Automate procurement:

- id: create_purchase_order
  type: sap_connector
  config:
    operation: createPurchaseOrder
    PurchasingOrganization: "1000"
    CompanyCode: "1000"
    PurchasingGroup: "{{ input.buyer_group }}"
    Vendor: "{{ input.vendor_id }}"
    DocumentCurrency: "USD"
    to_PurchaseOrderItem:
      - PurchaseOrderItemCategory: "Standard"
        Material: "{{ input.material_id }}"
        OrderQuantity: "{{ input.qty }}"
        NetPriceAmount: "{{ input.line_total }}"
        DeliveryDate: "{{ formatDate(input.delivery_date, 'yyyy-MM-dd') }}"

Example 3: Update Inventory

Sync stock levels:

- id: update_inventory
  type: sap_connector
  config:
    operation: getInventory
    material: "{{ input.material_id }}"
    plant: "{{ input.plant_id }}"

Then use the response:

- id: check_stock
  type: conditional
  config:
    condition: "{{ update_inventory_1.response.AvailableQuantity < 100 }}"
    true_path: "create_replenishment_order"
    false_path: "log_stock_ok"

Example 4: Get Business Partner (Vendor) Info

Retrieve supplier details:

- id: get_vendor
  type: sap_connector
  config:
    operation: getBusinessPartner
    partnerId: "{{ input.vendor_code }}"

Example 5: Create New Vendor

Onboard new suppliers:

- id: create_vendor
  type: sap_connector
  config:
    operation: createBusinessPartner
    CompanyCode: "1000"
    PartnerRole: "Supplier"
    PartnerName: "{{ input.vendor_name }}"
    CountryCode: "{{ input.country }}"
    CityName: "{{ input.city }}"
    PostalCode: "{{ input.postal_code }}"
    StreetAddress: "{{ input.address }}"
    PartnerPhoneNumber: "{{ input.phone }}"

Rate Limits

SAP rate limits vary by instance configuration:

  • Typical: 100-1000 requests per minute
  • Check with your SAP admin: Rate limits are instance-specific

Note: DeepChain handles retries with backoff.

Error Handling

Error What It Means How to Fix
InvalidPartner Customer/vendor ID doesn't exist Verify the partner ID in SAP
InvalidMaterial Material doesn't exist Check material master data
MissingRequiredField Required field not provided Check SAP field requirements
InvalidOrganization Sales/purchasing org doesn't exist Verify org code

Best Practices

1. Use Correct Organization Codes

Match your SAP configuration:

SalesOrganization: "1000"       # Match your SAP org
DistributionChannel: "10"       # Match channel config
CompanyCode: "1000"
PurchasingOrganization: "1000"

2. Validate Before Creating

Check for duplicates or conflicts:

- id: check_po_exists
  type: sap_connector
  config:
    operation: getPurchaseOrder
    purchaseOrderId: "{{ input.po_id }}"

- id: create_or_update
  type: conditional
  config:
    condition: "{{ check_po_exists_1.response.DocumentNumber }}"
    true_path: "skip"
    false_path: "create_po"

3. Use Material Master IDs

Always use internal SAP material IDs, not descriptions:

Material: "{{ input.sap_material_id }}"  # e.g., "MAT-001"

4. Format Dates Correctly

SAP expects ISO format:

DeliveryDate: "{{ formatDate(input.delivery, 'yyyy-MM-dd') }}"

5. Document Business Partner Data

When creating vendors/customers, ensure you have all required fields:

- CompanyCode
- PartnerRole
- PartnerName
- Country
- Address fields
- Contact information

Next Steps