Salesforce to SAP Account Migration

(0 reviews)

home

This template moves a large set of accounts from Salesforce to SAP. Trigger with an HTTP call either manually or programmatically.

Accounts are upserted so that the migration can be run multiple times without worrying about creating duplicates. This template uses Mule batching to make moving a large set of data easier and more transparent.

c31abb78-b827-4416-9fc3-633df5f768e5-image.png

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. You can use this template for free with the Mule Enterprise Edition, CloudHub, or as a trial in Anypoint Studio.

Use Case

This Anypoint template serves as a foundation for setting an online sync of accounts/customers from Salesforce to SAP.

Use this template to sync accounts from Salesforce to SAP customers for a one time synchronization by browsing the HTTP endpoint. The template fetches all accounts by specified criteria and sends it as IDoc to SAP to create or update customer accounts there.

Requirements have been set not only to be used as examples, but also to establish a starting point to adapt your integration to your requirements. This template leverages the Mule batch module.
The batch job is divided into Process and On Complete stages. The integration is triggered by the HTTP endpoint to fetch all the Salesforce Accounts suitable for migration. Fetched accounts are passed to the batch as input. In the batch the customer is fetched from SAP by its name. If it exists, its SAP Account Group is resolved against SAP. If it doesn't exist, then new customer number is fetched from SAP. Afterwards every such account from Salesforce is sent to SAP in form of iDoc XML where it is asynchronously updated or created.

Finally during the On Complete stage the template logs output statistics data into the console and send a notification email with the results of the batch execution.

Considerations

To make this template run, there are certain preconditions that must be considered. All of them deal with the preparations in both, that must be made for the template to run smoothly. Failing to do so could lead to unexpected behavior of the template.

Before continuing with the use of this template, see the SAP connector guide, that teaches you how to work with SAP and Anypoint Studio.

Disclaimer

This template uses Maven dependencies from MuleSoft to work. If you intend to run this template with Maven support, you need to add extra dependencies for SAP to the pom.xml file.

SAP Considerations

Here's what you need to know to get this template to work with SAP.

As a Data Destination

There is limitation on maximum length of Customer name in SAP. Therefore this template strips off all Account Name characters beyond 20.

Salesforce Considerations

As a Data Source

If the user who configured the template for the source system does not have at least read only permissions for the fields that are fetched, then an InvalidFieldFault API fault displays.

java.lang.RuntimeException: [InvalidFieldFault [ApiQueryFault
[ApiFault  exceptionCode='INVALID_FIELD'
exceptionMessage='Account.Phone, Account.Rating, Account.RecordTypeId,
Account.ShippingCity
^
ERROR at Row:1:Column:486
No such column 'RecordTypeId' on entity 'Account'. If you are attempting
to use a custom field, be sure to append the '__c' after the custom field
name. Reference your WSDL or the describe call for the appropriate names.'
]
row='1'
column='486'
]
]

Run it!

Simple steps to get this template running.

Running On Premises

This section helps you run 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:

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

For this template to run in Anypoint Studio, you need to install SAP libraries. See Install SAP Libraries.

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.

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

Application Configuration

  • http.port 9090

Batch Aggregator Configuration

  • page.size 1000

SalesForce Connector Configuration

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

SAP Connector Configuration

  • sap.jco.user SAP_USER
  • sap.jco.passwd SAP_PASS
  • sap.jco.sysnr 14
  • sap.jco.client 800
  • sap.jco.lang EN
  • sap.default.accountGroup ZAG2

SMTP Services Configuration

  • smtp.host smtp.gmail.com
  • smtp.port 587
  • smtp.user email@example.comsmtp.password password

Email Details

  • mail.from batch.migrateAccounts.migration@mulesoft.com
  • mail.to your@email.com
  • mail.subject Batch Job Finished Report

API Calls

There are no particular considerations for this template regarding API calls

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

config.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.

businessLogic.xml

Functional aspect of the template is implemented on this XML, directed by one flow responsible of executing the logic.

For the purpose of this particular template the mainFlow just executes the Batch Job which handles all the logic of it.

This flow has Error Handling that basically consists on invoking the On Error Propagate Component defined in errorHandling.xml file.

endpoints.xml

This file provides the inbound and outbound sides of your integration app.

This template has only an HTTP Listener as the way to trigger the use case.

HTTP Inbound Endpoint - Start Synchronization

  • ${http.port} is set as a property to be defined either on a property file or in CloudHub environment variables.
  • The path configured by default is migrateaccounts and you are free to change for the 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 migrated and filtered by the criteria specified.

errorHandling.xml

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.


Reviews

TypeTemplate
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onOct 10, 2018
Asset overview

Asset versions for 2.1.x

Asset versions
VersionActions
2.1.1

Categories

Pattern
MigrationNo values left to add
Object
AccountNo values left to add
Products
SalesforceSAPNo values left to add

Tags