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.
Prerequisites
Section titled “Prerequisites”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_RFCfor RFC accessS_TABU_DISfor table display- Appropriate authorization objects for business partner, material, and batch data
Supported Data Objects
Section titled “Supported Data Objects”| SAP Object | Cohera Entity | Sync Direction |
|---|---|---|
| Business Partner | Supplier | Bi-directional |
| Material Master | Component | SAP to Cohera |
| Batch | Batch | Bi-directional |
| Quality Info Record | Certificate | SAP to Cohera |
| Vendor Evaluation | Supplier Risk | SAP to Cohera |
Setup Guide
Section titled “Setup Guide”-
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
-
Configure OAuth 2.0 (Recommended)
Create an OAuth client in SAP:
Transaction: /IWFND/MAINT_SERVICEService: API_BUSINESS_PARTNERConfigure the OAuth scope:
API_BUSINESS_PARTNERAPI_MATERIAL_DOCUMENT_SRVAPI_BATCH_SRV
-
Create Cohera Connection
Use the API or dashboard to create the connection:
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 } }'connection_config = { "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 }}
response = requests.post( "https://api.cohera.io/v1/integrations/connections", headers={ "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }, json=connection_config)
connection = response.json()["data"]print(f"Connection created: {connection['id']}")const connectionConfig = { 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, },};
const response = await fetch( "https://api.cohera.io/v1/integrations/connections", { method: "POST", headers: { Authorization: `Bearer ${process.env.COHERA_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify(connectionConfig), });
const { data: connection } = await response.json();console.log(`Connection created: ${connection.id}`);-
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" -
Configure Field Mappings
Define how SAP fields map to Cohera entities (see Field Mapping section below).
-
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"
Authentication Options
Section titled “Authentication Options”OAuth 2.0 (Recommended)
Section titled “OAuth 2.0 (Recommended)”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" }}Basic Authentication
Section titled “Basic Authentication”For simpler setups or legacy configurations:
{ "authentication": { "type": "basic", "username": "COHERA_TECH_USER", "password": "your_password" }}Certificate-Based Authentication
Section titled “Certificate-Based Authentication”For high-security environments:
{ "authentication": { "type": "certificate", "client_certificate": "-----BEGIN CERTIFICATE-----...", "private_key": "-----BEGIN PRIVATE KEY-----...", "ca_certificate": "-----BEGIN CERTIFICATE-----..." }}Data Mapping
Section titled “Data Mapping”Supplier (Business Partner) Mapping
Section titled “Supplier (Business Partner) Mapping”{ "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" }}Component (Material) Mapping
Section titled “Component (Material) Mapping”{ "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"] }}Batch Mapping
Section titled “Batch Mapping”{ "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" } } ]}Sync Configuration
Section titled “Sync Configuration”Incremental Sync
Section titled “Incremental Sync”By default, Cohera performs incremental synchronization based on change timestamps:
{ "sync_config": { "mode": "incremental", "change_tracking_field": "LastChangeDateTime", "interval_minutes": 15 }}Full Sync
Section titled “Full Sync”Schedule periodic full synchronization to catch any missed changes:
{ "sync_config": { "full_sync_schedule": "0 2 * * 0", "incremental_interval_minutes": 15 }}Conflict Resolution
Section titled “Conflict Resolution”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" } } }}Outbound Sync (Cohera to SAP)
Section titled “Outbound Sync (Cohera to SAP)”Push updates from Cohera back to SAP for selected fields:
Supplier Updates
Section titled “Supplier Updates”{ "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"] }}Error Handling
Section titled “Error Handling”Common Errors
Section titled “Common Errors”| Error | Cause | Resolution |
|---|---|---|
AUTH_FAILED | Invalid credentials | Verify OAuth client or user credentials |
TIMEOUT | Network or SAP performance | Increase timeout, reduce batch size |
RATE_LIMITED | Too many requests | Reduce sync frequency |
FIELD_NOT_FOUND | Mapping references missing field | Update field mappings |
VALIDATION_ERROR | Data doesn’t match SAP requirements | Check transformation rules |
Retry Configuration
Section titled “Retry Configuration”{ "error_handling": { "max_retries": 3, "retry_delay_seconds": 60, "exponential_backoff": true, "alert_on_failure": ["integration-team@company.com"] }}Monitoring
Section titled “Monitoring”Sync Status Dashboard
Section titled “Sync Status Dashboard”Monitor sync health through the API:
curl -X GET "https://api.cohera.io/v1/integrations/connections/conn_sap_123/status" \ -H "Authorization: Bearer YOUR_API_KEY"Response
Section titled “Response”{ "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 } }}Troubleshooting
Section titled “Troubleshooting”Connection Test Fails
Section titled “Connection Test Fails”- Verify network connectivity (firewall rules, proxy settings)
- Check SAP service is activated (
/IWFND/MAINT_SERVICE) - Validate OAuth client configuration
- Ensure user has required authorizations
Data Not Syncing
Section titled “Data Not Syncing”- Check sync is enabled for the connection
- Verify field mappings are correct
- Review filters - ensure they include expected records
- Check for errors in sync history
Performance Issues
Section titled “Performance Issues”- Reduce batch size in sync configuration
- Adjust sync interval to reduce load
- Enable incremental sync instead of full sync
- Work with SAP team to optimize OData services