S/4HANA Cloud to Salesforce Partner Migration

(0 reviews)


This template moves a large set of partner objects from SAP S/4HANA Cloud to Salesforce. Partner objects are upserted so that migration can be executed multiple times without worrying concerns about duplicating information. This template uses MuleSoft's batching capabilities to move a large set of data easily and transparently from SAP S/4HANA Cloud into Salesforce.


  • Anypoint platform Enterprise Edition subscription or a trial account.
  • An entitlement to the Anypoint connector for SAP S/4HANA Cloud.

Use Case

This template helps you migrate partners from a SAP S/4HANA Cloud to a Salesforce instance, specify a filtering criteria, and specify a behavior when an account already exists in the destination instance.

This template leverages the Mule batch module. The batch job is divided into On Process and On Complete stages.

The migration process starts by fetching all the existing partners that match the filter criteria from SAP S/4HANA Cloud. The On Process stage matches accounts that are grouped and inserted or updated into Salesforce. Finally during the On Complete stage, the template outputs statistics data into the console and sends a notification email with the results of the batch execution.


To execute this template, there are certain preconditions that must be considered. All of them deal with the preparations in both systems (i.e. Salesforce and SAP S/4HANA Cloud), that must be made to execute the template smoothly.

Failing to do so can lead to unexpected behavior of the template.

SAP S/4HANA Considerations

Before using this template, please familiarize yourself with the S/4HANA Cloud connector.

Salesforce Considerations

Here's what you need to know about Salesforce to get this template to work:

Executing this Template

Simple steps to get this template running.

Running On Premises

In this section we help you execute this template on your computer.

Where to Download Anypoint Studio and the Mule Runtime

If you are new to Mule, download this software:

Note: Anypoint Studio requires JDK 8.

Importing a Template into Studio

In Studio, click the Exchange X icon in the upper left of the taskbar, log in with your Anypoint Platform credentials, search for the template, and click Open.

Running on Studio

After you import your template into Anypoint Studio, follow these steps to run it:

  • Locate the properties file mule.dev.properties, in src/main/resources.
  • Complete all the properties required as per the examples in the "Properties to Configure" section.
  • Right click the template project folder.
  • Hover your mouse over Run as.
  • Click Mule Application (configure).
  • Inside the dialog, select Environment and set the variable mule.env to the value dev.
  • Click Run.
Running on Mule Standalone

Update the properties in one of the property files, for example in mule.prod.properties, and run your app with a corresponding environment variable. In this example, use mule.env=prod.

Running on CloudHub

When creating your application in CloudHub, go to Runtime Manager > Manage Application > Properties to set the environment variables listed in Properties to Configure as well as the mule.env value.

After your app is running, if you chose s4hanapartnresmigration as the domain name to trigger the use case, you can browse to http://s4hanapartnresmigration.cloudhub.io/migratepartners to run the app, and the report gets sent to the emails you configured.

Deploying a Template in CloudHub

In Studio, right click your project name in Package Explorer and select Anypoint Platform > Deploy on CloudHub.

Properties to Configure

To use this template, configure properties such as credentials, configurations, etc.) in the properties file or in CloudHub from Runtime Manager > Manage Application > Properties. The sections that follow list example values.

Application Configuration

HTTP Connector Configuration

  • http.port 9090

Batch Aggregator Configuration

  • page.size 1000

SAP S4Hana Connector configuration

  • s4hana.baseUrl your.sap4hana.address.com
  • s4hana.username your.sap4hana.username
  • s4hana.password your.sap4hana.password
  • s4hana.partners.limit 100

Salesforce Connector Configuration

  • sfdc.username bob.dylan@orga
  • sfdc.password DylanPassword123
  • sfdc.securityToken avsfwCUl7apQs56Xq2AKi3X

SMTP Services Configuration

  • smtp.host smtp.example.com
  • smtp.port 587
  • smtp.user exampleuser
  • smtp.password examplepassword

Email Details

  • mail.from your.email@example.com
  • mail.to your.email@example.com
  • mail.subject Mail subject
API Calls

Salesforce imposes limits on the number of API Calls that can be made. Therefore calculating this amount is important. This template calls the API using this formula:

2X / ${page.size}

X is the number of accounts to be synchronized on each run.

Divide by ${page.size} because by default, accounts are gathered in groups of ${page.size} for each Upsert API Call in the aggregation step.

For instance if 10 records are fetched from origin instance, then 2 API calls are made (1 + 1).

Customize It!

This brief guide provides a high level understanding of how this template is built and how you can change it according to your needs. As Mule applications are based on XML files, this page describes the XML files used with this template. More files are available such as test classes and Mule application files, but to keep it simple, we focus on these XML files:

  • config.xml
  • businessLogic.xml
  • endpoints.xml
  • errorHandling.xml

This file provides the configuration for connectors and configuration properties. Only change this file to make core changes to the connector processing logic. Otherwise, all parameters that can be modified should instead be in a properties file, which is the recommended place to make changes.


The functional aspect of the template is implemented in this XML file, directed by one flow responsible of excecuting the logic.
For the purpose of this particular template the mainFlow uses a Mule batch job, which handles all the logic.


This is the file where you specify the inbound and outbound sides of your integration app.
This template only uses an HTTP Listener to trigger the use case.

HTTP Listener - Start Report Generation

  • ${http.port} is set as a property to be defined either in a property file or in the CloudHub environment variables.
  • The path configured by default is migratepartners and you are free to change it to one you prefer.
  • The host name for all endpoints in your CloudHub configuration should be defined as localhost. CloudHub routes requests from your application domain URL to the endpoint.
  • The endpoint is configured as a request-response since as a result of calling it the response is the total of accounts synced and filtered by the criteria specified.

This file handles how your integration reacts depending on the different exceptions. This file provides error handling that is referenced by the main flow in the business logic.

License Agreement

This template is subject to the conditions of the MuleSoft License Agreement. Review the terms of the license before downloading and using this template.



Published by
MuleSoft Organization
Published onNov 5, 2019
Asset overview

Asset versions for 2.1.x

Asset versions


SalesforceSAPNo values left to add
MigrationNo values left to add
SalesNo values left to add