Integrations

ServiceNow SAP Integration Guide

advancedSAP NetWeaver RFC with username/password or X.509 certificate authenticationSAP

The ServiceNow SAP integration enables organizations to synchronize critical business data between ServiceNow's IT Service Management platform and SAP's enterprise resource planning systems. This bi-directional integration solves the challenge of maintaining data consistency across HR, finance, asset management, and IT operations by automatically syncing employee records, configuration items, purchase orders, and incident data. Enterprise IT teams, SAP Basis administrators, and ServiceNow developers rely on this integration to eliminate manual data entry and ensure real-time visibility across business processes. The integration supports both uni-directional and bi-directional data flows, primarily triggered by scheduled imports, real-time API calls, and business rule automations. Data synchronization occurs through the Integration Hub's SAP spoke for modern implementations or custom SOAP/REST web services for legacy environments, with primary workflows managed within ServiceNow's Integration Hub and System Import Sets modules.

Prerequisites

  • ServiceNow Paris release or later with Integration Hub Professional license
  • SAP NetWeaver 7.0 or higher with RFC-enabled function modules
  • SAP user account with sufficient privileges for data extraction (SAP_BC_JSF, SAP_BC_WEBSERVICE, or equivalent)
  • MID Server installed and configured in your network with SAP connectivity
  • ServiceNow Import Set Tables created for target SAP entities
  • SAP GUI access for testing RFC connections and viewing ABAP error logs
  • Network connectivity between ServiceNow MID Server and SAP application server on ports 3300-3399

Architecture Overview

The ServiceNow SAP integration leverages the Integration Hub's SAP spoke (SAP Integration Pack) which provides pre-built actions for common SAP operations including user synchronization, asset imports, and incident creation. Authentication is established using SAP NetWeaver RFC connections stored in ServiceNow's Connection & Credential Alias records, supporting both username/password and SSO certificate-based authentication. Data flows bi-directionally with scheduled imports pulling SAP data into ServiceNow Import Set Tables, while real-time updates push ServiceNow changes back to SAP via RFC function calls or web services. A MID Server is required for all SAP communications as it handles the SAP Java Connector (JCo) libraries and maintains persistent RFC connections to SAP systems. Rate limiting considerations include SAP's dialog work process availability and RFC connection pooling, with typical limits of 50-100 concurrent RFC connections per SAP application server depending on system configuration.

Sourdough
Chrome Extension

Sourdough: ServiceNow Monitoring and Analytics

A Chrome extension for ServiceNow Admins and Developers with essential tools, analytics, graphs and monitoring features.

Instance HealthGraphs & ChartsAPI HealthDeveloper ToolsQuick SearchInstance Switcher
Add to Chrome

Free to install. Pro $5/month after a 14-day no-card trial.
Pro requires the ServiceNow admin role. Upgrade inside the extension.

Overview
Tasks
CMDB
API
Metrics
Monitor
Internals
Instance:sourdoughdev·Version:Yokohama
Instance StateONLINE
System StatusFully Operational
Session Timeout90 minutes
Logged-In Sessions2 (20 active)
Build Nameyokohama-12-18-2024_p1
IP Address10.159.128.43
Instance HealthHealth Score: 90%
🔥 5dSourdough (Chrome Plugin)Dark Mode

Implementation Steps

1

Install and configure the SAP Integration Pack from the ServiceNow Store

Navigate to System Applications > All Available Applications > All and search for 'SAP Integration Pack' to install the official spoke. Once installed, go to Integration Hub > Connections & Credentials > Connection Aliases and create a new connection alias named 'SAP_Production' or similar. Select 'SAP' as the connection type and configure the SAP application server details including hostname, system number, and client. The connection alias will be referenced by all SAP spoke actions and provides centralized connection management.

2

Create SAP credentials and store them securely in ServiceNow

Navigate to Connections & Credentials > Credentials and create a new credential record with type 'Basic Auth Credentials'. Enter your SAP username in the 'User name' field and SAP password in the 'Password' field, ensuring the user has appropriate SAP authorizations for data access. Set the credential name to match your connection alias naming convention like 'SAP_Production_Creds'. Associate this credential with your SAP connection alias by editing the connection alias and selecting the credential in the 'Credential' field.

3

Configure MID Server for SAP connectivity and install JCo libraries

Download the SAP Java Connector (JCo) libraries from the SAP Software Download Center and copy them to your MID Server's agent/lib directory. Navigate to MID Server > Servers and validate your MID Server shows 'Up' status, then add the SAP-specific parameters including 'sap.jco.destination.peak_limit=100' and 'sap.jco.destination.pool_capacity=10' to optimize connection pooling. Test the connectivity by navigating to Integration Hub > Action Designer and creating a test flow using the 'SAP - Test Connection' action. Verify successful RFC connection establishment in the MID Server logs located at agent/logs/agent0.log.txt.

4

Create Import Set Tables for SAP data structures

Navigate to System Import Sets > Administration > Import Set Tables and create tables matching your SAP data structures such as 'u_import_sap_users' for HR data and 'u_import_sap_assets' for asset management. Define columns corresponding to SAP fields like PERNR for personnel number, BUKRS for company code, and ANLN1 for asset numbers. Configure appropriate column types (string, integer, date) and lengths matching SAP field definitions to prevent data truncation. Create corresponding Transform Maps by navigating to System Import Sets > Administration > Transform Maps to map imported SAP data to ServiceNow tables like sys_user and cmdb_ci.

5

Configure SAP spoke actions for user and asset synchronization

Navigate to Integration Hub > Action Designer and create a new action using the SAP spoke's 'Execute RFC Function' action as the foundation. Configure the action to call SAP RFC function modules like 'BAPI_EMPLOYEE_GETDATA' for user synchronization or 'BAPI_FIXEDASSET_GETLIST' for asset imports. Set up the RFC function parameters including import, export, and table parameters according to SAP's BAPI documentation. Map the RFC response data to your Import Set Tables using the action's output mapping configuration, ensuring proper data type conversion and error handling for failed RFC calls.

ServiceNow Script
var sapAction = new sn_ih_integration.IntegrationHub();
var actionName = 'SAP - Execute RFC Function';
var inputs = {
    'connection_alias': 'SAP_Production',
    'function_name': 'BAPI_EMPLOYEE_GETDATA',
    'import_parameters': '{
        "USERID": "' + current.user_name + '",
        "WITH_LOGON_DATA": "X"
    }'
};
var result = sapAction.execute(actionName, inputs);
if (result.status == 'success') {
    gs.info('SAP user data retrieved: ' + result.output);
} else {
    gs.error('SAP RFC call failed: ' + result.error_message);
}
6

Implement incident creation from SAP ABAP error logs

Create a scheduled job to query SAP's SM21 system log or custom ABAP error tables using the 'SAP - Execute RFC Function' action calling 'BAPI_SYSTEM_MS_GETMSG' or custom Z-function modules. Navigate to System Definition > Scheduled Jobs and create a job that runs every 15-30 minutes to check for new ABAP errors or system messages with severity levels of 'E' (Error) or 'A' (Abend). Configure the job to parse SAP error messages and create ServiceNow incident records with appropriate categorization, priority mapping based on SAP message class, and assignment to SAP Basis support groups. Include SAP-specific fields like transaction code, program name, and system ID in the incident description for faster resolution.

ServiceNow Script
var gr = new GlideRecord('incident');
gr.initialize();
gr.short_description = 'SAP ABAP Error: ' + sapError.message_text;
gr.description = 'System: ' + sapError.system_id + '\n' +
                'Program: ' + sapError.program_name + '\n' +
                'Transaction: ' + sapError.transaction_code + '\n' +
                'Error Class: ' + sapError.message_class + '\n' +
                'Error Number: ' + sapError.message_number;
gr.priority = (sapError.severity == 'A') ? '1' : '2';
gr.category = 'Software';
gr.subcategory = 'SAP Application';
gr.assignment_group = 'SAP Basis Team';
gr.caller_id = gs.getUserID();
var incidentId = gr.insert();
gs.info('Created incident ' + incidentId + ' for SAP error: ' + sapError.message_id);
7

Configure bi-directional change management workflows

Navigate to Workflow > Workflow Editor and create workflows that sync ServiceNow Normal Changes with SAP's Change Request Management (CRM) or custom change tracking tables. Configure outbound integration to create SAP transport requests when ServiceNow changes move to 'Implement' state using the 'SAP - Execute RFC Function' action with 'TR_READ_COMM' or custom Z-functions. Set up inbound integration to update ServiceNow change records when SAP transport requests complete by polling SAP tables E070 and E071 for transport status updates. Include approval workflows that sync with SAP's approval processes and maintain traceability between ServiceNow change numbers and SAP transport request numbers in custom fields.

ServiceNow Script
// Outbound: Create SAP transport request
var sapTransport = new sn_ih_integration.IntegrationHub();
var inputs = {
    'connection_alias': 'SAP_Production',
    'function_name': 'TR_RELEASE_REQUEST',
    'import_parameters': '{
        "IV_REQUEST": "' + current.sap_transport_number + '",
        "IV_SUCCESS_MSG": "X"
    }'
};
var result = sapTransport.execute('SAP - Execute RFC Function', inputs);
if (result.status == 'success' && result.output.EV_SUCCESS == 'X') {
    current.state = '3'; // Implement
    current.sap_release_status = 'Released';
    current.update();
    gs.addInfoMessage('SAP transport request released successfully');
}
8

Test the integration and implement error handling

Navigate to Integration Hub > Action Designer and use the 'Test' functionality to validate each SAP spoke action with sample data, verifying successful RFC connections and data retrieval. Create comprehensive error handling by implementing try-catch blocks in custom scripts and configuring spoke action failure paths to create ServiceNow events or notifications. Test various failure scenarios including SAP system downtime, invalid credentials, and network connectivity issues to ensure graceful degradation. Set up monitoring dashboards using ServiceNow's Integration Hub monitoring capabilities and configure email notifications for integration failures by creating business rules on the Integration Hub execution logs.

ServiceNow Script
try {
    var sapResult = new sn_ih_integration.IntegrationHub().execute('SAP - Get User Data', inputs);
    if (sapResult.status !== 'success') {
        throw new Error('SAP integration failed: ' + sapResult.error_message);
    }
    // Process successful SAP response
    var userData = JSON.parse(sapResult.output);
    gs.info('Successfully retrieved SAP user data for ' + userData.BNAME);
} catch (ex) {
    gs.error('SAP integration error: ' + ex.message);
    var event = new GlideRecord('sysevent');
    event.initialize();
    event.name = 'sap.integration.failure';
    event.parm1 = current.getTableName();
    event.parm2 = current.getUniqueValue();
    event.instance = gs.getProperty('instance_name');
    event.insert();
}

Common Use Cases

Employee lifecycle management and user provisioning

Automatically sync employee data from SAP HR (PA) modules to ServiceNow's sys_user table when new hires are processed or employee information changes in SAP. The integration triggers on SAP HR infotype changes (IT0001, IT0002) and updates ServiceNow user records with current organizational data, manager relationships, cost centers, and employment status. This ensures ServiceNow's CMDB and service catalog permissions remain synchronized with authoritative HR data. Business value includes reduced manual user administration, improved security through timely deprovisioning, and accurate organizational reporting across IT service management processes.

Asset and configuration item synchronization

Import fixed assets, equipment, and IT infrastructure data from SAP Asset Management (AM) and Plant Maintenance (PM) modules into ServiceNow's CMDB as configuration items. The integration maps SAP asset master records, including asset numbers (ANLN1), descriptions, locations (STORT), cost centers (KOSTL), and depreciation data to appropriate CI classes in ServiceNow. Scheduled imports run daily to capture asset transfers, retirements, and new acquisitions, while real-time updates handle critical asset status changes. This provides comprehensive asset visibility for IT service management, change impact analysis, and financial reporting while maintaining SAP as the authoritative source for asset data.

Incident creation from SAP system monitoring and ABAP dumps

Automatically create ServiceNow incidents when SAP systems generate critical errors, ABAP short dumps, or performance threshold violations detected by SAP Solution Manager or custom monitoring programs. The integration polls SAP's ST22 transaction data for ABAP runtime errors and SM21 system logs for critical messages, then creates categorized incidents with SAP-specific context including transaction codes, user sessions, and system performance metrics. Incidents are automatically assigned to SAP Basis teams with priority mapping based on error severity and business impact. This ensures rapid response to SAP system issues and provides comprehensive audit trails for system stability reporting.

Change management workflow integration

Synchronize ServiceNow Normal Changes with SAP's Transport Management System (TMS) and Change Request Management to ensure coordinated release management across both platforms. When ServiceNow changes reach implementation phase, the integration automatically creates corresponding SAP transport requests and tracks their progression through SAP system landscapes (DEV -> QAS -> PRD). Transport release status updates from SAP trigger ServiceNow change state transitions and closure workflows. This integration maintains complete traceability between business changes managed in ServiceNow and technical implementations managed through SAP's transport system, ensuring compliance with change control procedures.

Purchase requisition and procurement workflow automation

Integrate ServiceNow's Service Catalog with SAP Materials Management (MM) to automate purchase requisition creation and approval workflows for IT goods and services. When users submit catalog requests in ServiceNow, the integration creates corresponding purchase requisitions in SAP with proper account assignments, cost centers, and approval routing based on ServiceNow's workflow decisions. SAP purchase order confirmations and goods receipt updates flow back to ServiceNow to update request fulfillment status and trigger asset creation processes. This streamlines IT procurement while maintaining financial controls and spending visibility across both platforms.

Troubleshooting

RFC connection fails with 'JCO_ERROR_LOGON_FAILURE' or RFC authorization errors

First, verify the SAP user credentials have not expired by testing logon through SAP GUI. Check the user's authorization profile in SAP transaction SU01 and ensure they have necessary RFC authorizations including S_RFC, S_USER_GRP, and object-specific authorizations for accessed BAPIs. In ServiceNow, validate the credential record contains the correct username and password, and verify the connection alias points to the correct SAP system and client. Review MID Server logs for detailed RFC error messages and consult SAP Note 460089 for RFC authorization troubleshooting guidance.

SAP spoke actions timeout or return incomplete data sets

Increase timeout values in the SAP connection alias configuration and verify SAP system performance is adequate for the requested data volume. Check SAP work process availability using SM50/SM66 transactions and consider implementing data pagination for large result sets using RFC table parameters like MAXROWS or date range filtering. Review MID Server system resources (CPU, memory) and increase JVM heap size if necessary by modifying the wrapper.conf file. Consider scheduling large data imports during off-peak hours to avoid SAP system performance impact.

Import Set transformations fail with data type conversion errors or field length truncation

Navigate to System Import Sets > Import Set Tables and verify column definitions match SAP field characteristics including data types and maximum lengths as documented in SAP table definitions (SE11). Review the Transform Map field mappings and implement JavaScript transformation functions to handle SAP-specific data formats like dates (YYYYMMDD) and decimal numbers with implicit decimal places. Check the Import Set processing logs for specific error details and implement data validation rules to handle null values and invalid characters that may exist in legacy SAP data.

Duplicate incident creation from repeated SAP error log processing

Implement de-duplication logic by creating custom fields to track processed SAP message IDs, timestamps, and system identifiers to prevent processing the same error multiple times. Use ServiceNow's duplicate detection rules on the incident table with SAP-specific matching criteria including system ID, message class, message number, and occurrence timestamp. Consider implementing a 'cooling-off' period where similar errors within a defined time window (e.g., 30 minutes) are grouped into a single incident rather than creating separate records. Store the last processed timestamp for each SAP system to ensure incremental error log processing.

SAP transport request integration fails with 'Transport request not found' or status update errors

Verify the ServiceNow change record contains valid SAP transport request numbers in the correct format (system_ID K nnnnnnn for workbench requests) and that the requests exist in the SAP system using SE09 transaction. Check that the RFC user has appropriate authorization for transport functions including S_CTS_ADMI and object class 'TRAN' with activities for transport release and import. Implement error handling to distinguish between temporary SAP system unavailability and permanent transport request issues, and configure retry mechanisms with exponential backoff for transient failures. Review SAP system logs (SM21) for transport-related error messages that may indicate underlying TMS configuration issues.

MID Server SAP integration stops working after SAP system refresh or transport imports

SAP system refreshes often change system identifiers, RFC destinations, or user accounts which break established connections. Validate all connection parameters including system number, client, and application server hostname against the refreshed SAP system configuration in transaction SM59. Check if RFC destinations used by the integration still exist and have correct technical settings including gateway host, gateway service, and activation status. Re-test RFC user accounts as system refreshes may require password resets or authorization profile re-assignment, and update ServiceNow credentials accordingly. Restart the MID Server to clear cached RFC connections and force re-establishment of JCo destination pools with updated parameters.

Pro Tips

  • Implement SAP data archiving awareness by configuring your integration to handle archived records gracefully, using SAP's archive information structures or READ_ARCHIVE function modules to retrieve historical data that may have been moved from active tables to archive files.
  • Leverage SAP's Change Documents (CDHDR/CDPOS tables) to implement real-time delta synchronization instead of full data imports, significantly reducing system load and improving integration performance while ensuring you capture all relevant changes.
  • Create custom SAP function modules (Z-functions) for complex data extractions rather than relying solely on standard BAPIs, as this allows you to implement ServiceNow-specific logic, error handling, and performance optimizations directly in the SAP system.
  • Implement connection pooling optimization by configuring multiple SAP connection aliases for different data types or business processes, allowing you to tune connection parameters, timeout values, and retry logic specific to each integration pattern.
  • Use ServiceNow's Integration Hub bulk data operations combined with SAP's internal table processing to handle large data volumes efficiently, implementing proper commit strategies and progress tracking to prevent RFC timeouts on massive data synchronizations.
  • Establish comprehensive monitoring by creating custom ServiceNow dashboards that track SAP integration metrics including RFC call volumes, error rates, data synchronization lag times, and SAP system availability to proactively identify performance trends and potential issues.

Known Limitations

  • SAP RFC connections are limited by the SAP system's configured dialog work processes and gateway limitations, typically supporting 50-100 concurrent connections per application server, which may require connection pooling strategies for high-volume integrations. Performance degrades significantly when RFC connection limits are exceeded, potentially impacting both ServiceNow and SAP system responsiveness.
  • The SAP Integration Hub spoke requires a MID Server with sufficient memory allocation (minimum 4GB recommended) and SAP JCo library compatibility, limiting deployment options in cloud-only ServiceNow instances without on-premises infrastructure. JCo library updates must be manually coordinated with SAP kernel upgrades and ServiceNow release schedules.
  • Real-time bi-directional synchronization is challenging due to SAP's batch-oriented architecture and database locking mechanisms, often requiring scheduled polling or SAP workflow-triggered updates rather than true real-time data exchange. Complex SAP customizations or heavily modified data structures may not be compatible with standard Integration Hub spoke actions.
  • SAP authorization concepts (authorization objects, profiles, roles) are complex and may require dedicated SAP security expertise to properly configure RFC users with minimal necessary privileges. Over-privileged RFC users pose security risks, while under-privileged users cause integration failures that can be difficult to diagnose.
  • Data volume limitations exist for single RFC calls, typically restricted to 10,000-50,000 records per transaction depending on SAP system configuration and network bandwidth, requiring pagination strategies for large data sets like complete employee or asset master data extractions.

Frequently Asked Questions

Can I use the SAP Integration Hub spoke with SAP S/4HANA Cloud systems?

The SAP spoke works with SAP S/4HANA Cloud systems, but with limitations due to the restricted RFC access in cloud environments. You'll need to use SAP's Cloud Connector to establish secure connectivity between ServiceNow and SAP S/4HANA Cloud, and many standard RFC function modules may not be available. Consider using SAP's OData APIs or REST services through ServiceNow's REST Message functionality as an alternative integration method. SAP provides specific API enablement for common integration scenarios like user management and asset synchronization in S/4HANA Cloud.

How do I handle SAP custom fields and Z-tables in the integration?

Custom SAP fields and Z-tables require creating custom RFC function modules (Z-functions) in SAP that expose the specific data structures you need to integrate. The ServiceNow SAP spoke can call these custom functions using the 'Execute RFC Function' action, but you'll need to manually configure the import/export parameters and table structures. Create corresponding custom fields in ServiceNow Import Set Tables and Transform Maps to accommodate the Z-table data. Work with your SAP development team to ensure custom functions follow SAP development standards and include proper error handling and authorization checks.

What's the recommended frequency for scheduled SAP data imports?

The optimal frequency depends on data volatility and business requirements, but generally run user/HR data imports once daily during off-peak hours (typically overnight), asset data imports weekly unless high asset turnover exists, and critical monitoring data every 15-30 minutes. More frequent imports increase SAP system load and may impact performance for interactive users. Consider implementing delta-based synchronization using SAP Change Documents or modification timestamps to reduce data volumes and system impact. Always coordinate import schedules with SAP Basis administrators to avoid conflicts with SAP batch jobs, backups, and maintenance windows.

How do I secure SAP RFC credentials and prevent unauthorized access?

Store SAP credentials using ServiceNow's encrypted Credential records and restrict access using ACLs that limit credential visibility to integration administrators and service accounts. In SAP, create dedicated RFC users with minimal necessary authorizations using composite roles rather than broad SAP_ALL access, and implement SAP's authorization trace (ST01) to identify exact authorization requirements. Enable SAP's security audit log to monitor RFC user activities and set up password policies with regular rotation schedules. Consider implementing certificate-based authentication where supported to eliminate password-based authentication risks, and use SAP's trusted RFC connections between systems when possible.

Can I integrate with multiple SAP systems (DEV, QAS, PRD) from a single ServiceNow instance?

Yes, create separate Connection Aliases and Credential records for each SAP system landscape, using naming conventions like 'SAP_DEV', 'SAP_QAS', and 'SAP_PRD' to clearly identify target systems. Configure different Integration Hub flows or use conditional logic within flows to route data appropriately based on environment or data type. Implement proper change management controls to prevent accidental production data modifications during development and testing activities. Consider using ServiceNow's multiple MID Servers if different network zones or security requirements exist for each SAP environment, and maintain separate monitoring and alerting configurations for each system integration.

What happens to ServiceNow data if the SAP system becomes unavailable?

ServiceNow continues operating with cached/local data when SAP is unavailable, but new data synchronization stops until connectivity is restored. Implement error handling in Integration Hub flows to gracefully handle SAP downtime by creating events, notifications, or incident records to alert administrators. Configure retry mechanisms with exponential backoff to automatically resume integration when SAP becomes available, and consider implementing a 'last successful sync' timestamp to track data freshness. For critical business processes, design fallback procedures that allow ServiceNow operations to continue with potentially stale data while maintaining audit trails of actions taken during SAP unavailability periods.

How do I troubleshoot SAP ABAP code issues when developing custom integration functions?

Use SAP's ABAP debugger (transaction SE80 or ADT in Eclipse) to step through custom function module code, and implement comprehensive error handling using SAP's message class framework to return meaningful error descriptions to ServiceNow. Enable SAP's RFC trace using transaction ST05 to monitor data flow and performance bottlenecks in custom functions. Create ABAP unit tests for custom integration functions to validate functionality independently of ServiceNow, and use SAP's function module test environment (SE37) to test functions with sample data. Maintain detailed documentation of custom function interfaces and implement proper exception handling that returns structured error information rather than generic system dumps.

Test Your Knowledge

Quick 3-question quiz — see how your ServiceNow skills stack up.

Question 1 of 3Performance

A list view on a table with millions of records is slow. Best fix?

Select an answer to continue