Skip to content

SAP S/4HANA Integration

This guide covers the setup and configuration of the Cohera SAP S/4HANA integration. Once configured, Cohera synchronizes supplier data, material masters, batch information, and quality data with your SAP system.

Before you begin, ensure you have:

  • SAP S/4HANA 1909 or later
  • SAP Communication Management configured
  • OAuth 2.0 or API key authentication enabled
  • Network connectivity from Cohera to your SAP system
  • The following SAP authorizations:
    • S_RFC for RFC access
    • S_TABU_DIS for table display
    • Appropriate authorization objects for business partner, material, and batch data
SAP ObjectCohera EntitySync Direction
Business PartnerSupplierBi-directional
Material MasterComponentSAP to Cohera
BatchBatchBi-directional
Quality Info RecordCertificateSAP to Cohera
Vendor EvaluationSupplier RiskSAP to Cohera
  1. Create SAP Communication Arrangement

    In SAP S/4HANA, create a communication arrangement for the Cohera integration:

    • Navigate to Communication Management > Communication Arrangements
    • Create a new arrangement using scenario SAP_COM_0008 (Business Partner Integration)
    • Note the service URL and authentication details
  2. Configure OAuth 2.0 (Recommended)

    Create an OAuth client in SAP:

    Transaction: /IWFND/MAINT_SERVICE
    Service: API_BUSINESS_PARTNER

    Configure the OAuth scope:

    • API_BUSINESS_PARTNER
    • API_MATERIAL_DOCUMENT_SRV
    • API_BATCH_SRV
  3. Create Cohera Connection

    Use the API or dashboard to create the connection:

Terminal window
curl -X POST "https://api.cohera.io/v1/integrations/connections" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "SAP S/4HANA Production",
"type": "sap_s4hana",
"authentication": {
"type": "oauth2",
"client_id": "COHERA_INTEGRATION",
"client_secret": "your_client_secret",
"token_url": "https://sap.yourcompany.com/sap/bc/sec/oauth2/token"
},
"endpoints": {
"api_base": "https://sap.yourcompany.com/sap/opu/odata/sap"
},
"sync_config": {
"direction": "bidirectional",
"interval_minutes": 15,
"batch_size": 100
}
}'
  1. Test the Connection

    Verify connectivity before enabling sync:

    Terminal window
    curl -X POST "https://api.cohera.io/v1/integrations/connections/conn_sap_123/test" \
    -H "Authorization: Bearer YOUR_API_KEY"
  2. Configure Field Mappings

    Define how SAP fields map to Cohera entities (see Field Mapping section below).

  3. Enable Synchronization

    Start the sync process:

    Terminal window
    curl -X POST "https://api.cohera.io/v1/integrations/connections/conn_sap_123/enable" \
    -H "Authorization: Bearer YOUR_API_KEY"

OAuth 2.0 provides secure, token-based authentication with automatic refresh.

{
"authentication": {
"type": "oauth2",
"client_id": "COHERA_INTEGRATION",
"client_secret": "your_client_secret",
"token_url": "https://sap.yourcompany.com/sap/bc/sec/oauth2/token",
"scope": "API_BUSINESS_PARTNER API_MATERIAL_DOCUMENT_SRV"
}
}

For simpler setups or legacy configurations:

{
"authentication": {
"type": "basic",
"username": "COHERA_TECH_USER",
"password": "your_password"
}
}

For high-security environments:

{
"authentication": {
"type": "certificate",
"client_certificate": "-----BEGIN CERTIFICATE-----...",
"private_key": "-----BEGIN PRIVATE KEY-----...",
"ca_certificate": "-----BEGIN CERTIFICATE-----..."
}
}
{
"entity_type": "supplier",
"source_object": "A_BusinessPartner",
"field_mappings": [
{
"source": "BusinessPartner",
"target": "supplier_code",
"required": true
},
{
"source": "BusinessPartnerFullName",
"target": "name",
"required": true
},
{
"source": "BusinessPartnerCategory",
"target": "attributes.category",
"transformation": {
"type": "lookup",
"values": {
"1": "organization",
"2": "supplier"
}
}
},
{
"source": "to_BusinessPartnerAddress/Country",
"target": "attributes.country"
},
{
"source": "to_BusinessPartnerAddress/CityName",
"target": "attributes.city"
},
{
"source": "to_BusinessPartnerAddress/PostalCode",
"target": "attributes.postal_code"
},
{
"source": "CreationDate",
"target": "attributes.sap_created_date",
"transformation": {
"type": "date_format",
"input_format": "YYYYMMDD",
"output_format": "ISO8601"
}
}
],
"filters": {
"BusinessPartnerCategory": "2",
"BusinessPartnerIsBlocked": false
},
"sync_key": {
"source": "BusinessPartner",
"target": "supplier_code"
}
}
{
"entity_type": "component",
"source_object": "A_Product",
"field_mappings": [
{
"source": "Product",
"target": "component_code",
"required": true
},
{
"source": "ProductDescription",
"target": "name"
},
{
"source": "ProductType",
"target": "attributes.type",
"transformation": {
"type": "lookup",
"values": {
"ROH": "raw_material",
"HALB": "semi_finished",
"FERT": "finished_product"
}
}
},
{
"source": "BaseUnit",
"target": "attributes.base_unit"
},
{
"source": "to_ProductPlant/PurchasingGroup",
"target": "attributes.purchasing_group"
}
],
"filters": {
"ProductType": ["ROH", "HALB"]
}
}
{
"entity_type": "batch",
"source_object": "A_Batch",
"field_mappings": [
{
"source": "Batch",
"target": "batch_number",
"required": true
},
{
"source": "Material",
"target": "component_ref",
"transformation": {
"type": "entity_lookup",
"entity_type": "component",
"lookup_field": "component_code"
}
},
{
"source": "ManufactureDate",
"target": "attributes.manufacture_date"
},
{
"source": "ShelfLifeExpirationDate",
"target": "attributes.expiry_date"
},
{
"source": "Supplier",
"target": "supplier_ref",
"transformation": {
"type": "entity_lookup",
"entity_type": "supplier",
"lookup_field": "supplier_code"
}
}
]
}

By default, Cohera performs incremental synchronization based on change timestamps:

{
"sync_config": {
"mode": "incremental",
"change_tracking_field": "LastChangeDateTime",
"interval_minutes": 15
}
}

Schedule periodic full synchronization to catch any missed changes:

{
"sync_config": {
"full_sync_schedule": "0 2 * * 0",
"incremental_interval_minutes": 15
}
}

Configure how conflicts are resolved when data differs between systems:

{
"sync_config": {
"conflict_resolution": {
"default_strategy": "sap_wins",
"field_overrides": {
"attributes.qualification_status": "cohera_wins",
"attributes.risk_level": "cohera_wins"
}
}
}
}

Push updates from Cohera back to SAP for selected fields:

{
"outbound_sync": {
"enabled": true,
"entity_type": "supplier",
"target_object": "A_BusinessPartner",
"writable_fields": [
{
"source": "attributes.cohera_qualification_status",
"target": "YY1_CoheraQualStatus_bus"
},
{
"source": "attributes.risk_score",
"target": "YY1_CoheraRiskScore_bus"
}
],
"triggers": ["qualification_status_change", "risk_assessment_update"]
}
}
ErrorCauseResolution
AUTH_FAILEDInvalid credentialsVerify OAuth client or user credentials
TIMEOUTNetwork or SAP performanceIncrease timeout, reduce batch size
RATE_LIMITEDToo many requestsReduce sync frequency
FIELD_NOT_FOUNDMapping references missing fieldUpdate field mappings
VALIDATION_ERRORData doesn’t match SAP requirementsCheck transformation rules
{
"error_handling": {
"max_retries": 3,
"retry_delay_seconds": 60,
"exponential_backoff": true,
"alert_on_failure": ["integration-team@company.com"]
}
}

Monitor sync health through the API:

Terminal window
curl -X GET "https://api.cohera.io/v1/integrations/connections/conn_sap_123/status" \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": {
"connection_id": "conn_sap_123",
"status": "healthy",
"last_sync": {
"timestamp": "2024-01-20T14:00:00Z",
"direction": "inbound",
"status": "success",
"records": {
"suppliers": {"synced": 45, "created": 2, "updated": 43, "errors": 0},
"components": {"synced": 120, "created": 5, "updated": 115, "errors": 0}
},
"duration_seconds": 23
},
"metrics_24h": {
"total_syncs": 96,
"success_rate": 100,
"records_synced": 4350,
"avg_duration_seconds": 22
}
}
}
  1. Verify network connectivity (firewall rules, proxy settings)
  2. Check SAP service is activated (/IWFND/MAINT_SERVICE)
  3. Validate OAuth client configuration
  4. Ensure user has required authorizations
  1. Check sync is enabled for the connection
  2. Verify field mappings are correct
  3. Review filters - ensure they include expected records
  4. Check for errors in sync history
  1. Reduce batch size in sync configuration
  2. Adjust sync interval to reduce load
  3. Enable incremental sync instead of full sync
  4. Work with SAP team to optimize OData services