Salesforce to SAP Product Broadcast
home
Broadcast using one way sync changes or creations of products from Salesforce to SAP as materials in real time.
The detection criteria and fields to move are configurable. Additional systems can be added to be notified of the changes. Real time synchronization is achieved either via rapid polling of Salesforce or outbound notifications to reduce the number of API calls.
This template uses Mule batching and watermarking capabilities to capture only recent changes, and to efficiently process large amounts of records.
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 template serves as a foundation for setting an online sync of products or materials from Salesforce to SAP. Every time there is a new product or a change in already existing one in Salesforce instance, the template fetches it and upserts it into SAP. 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 a scheduler to Salesforce products. New or modified products with non-empty product codes are passed to the batch as input. In the batch the material is fetched from SAP by its ProductCode
. Depending on the result, the product is created or updated in SAP. Finally during the On Complete stage the template logs output statistics data into the console.
Considerations
To make this template run, there are 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 to use this template, see the SAP connector guide to work with SAP and Anypoint Studio.
Disclaimer
This template uses a few private 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. See SAP XML and Maven Support.
SAP Considerations
Here's what you need to know to get this template to work with SAP.
As a Data Destination
This template uses custom BAPI functions. Use these steps:
- Create structure
ZMMST_ENH_MARA
in transactionSE11
as per its definition in filestructure_ZMMST_ENH_MARA.abap
- Create table type
ZMMTTY_ENH_MARA
in transactionSE11
as per its definition in filetable_type_ZMMTTY_ENH_MARA.abap
- Create message class called
ZMULESOFTINTEGRATION
in transactionSE91
as per definition in filemsg_class_ZMULESOFTINTEGRATION.abap
- Create function module
ZMMFM_MATERIAL_GETLIST
in transactionSE37
as per source fileZMMFM_MATERIAL_GETLIST.abap
Referenced files are in [src/main/resources] directory.
Salesforce Considerations
- Where can I check that the field configuration for my Salesforce instance is the right one? See: Salesforce: Checking Field Accessibility for a Particular Field.
- How can I modify the Field Access Settings? See: Salesforce: Modifying Field Access Settings.
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
In this section we help 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:
- Locate the properties file
mule.dev.properties
, in src/main/resources. - Complete all the properties required 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 valuedev
. - Click
Run
.
For this template to run in Anypoint Studio, you need to install SAP Libraries.
Run 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
.
Run 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.
Deploy 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
- scheduler.frequency
10000
- scheduler.start.delay
5000
Watermarking default last query timestamp for example 2018-12-13T03:00:59Z
- watermark.default.expression
2018-06-26T12:30:00.000Z
SAP Connector Configuration
- sap.jco.ashost
your.sap.address.com
- sap.jco.user
SAP_USER
- sap.jco.passwd
SAP_PASS
- sap.jco.sysnr
14
- sap.jco.client
800
- sap.jco.lang
EN
SAP Material properties Configuration
- sap.material.type
ZHTI
- sap.material.industrySector
T
- sap.material.baseUnitOfMeasurement
KGS
SalesForce Connector Configuration
- sfdc.username
bob.dylan@sfdc
- sfdc.password
DylanPassword123
- sfdc.securityToken
avsfwCUl7apQs56Xq2AKi3X
API Calls
Salesforce imposes limits on the number of API Calls that can be made. However, in this template, only one call per poll cycle is done to retrieve all the information required.
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 in this XML file, directed by a batch job that's responsible for creations or updates. The several message processors constitute four high level actions that fully implement the logic of this template:
The integration is triggered by scheduler to Salesforce Products. New or modified products are passed to the batch as input.
In the batch the material is fetched from SAP by its
ProductCode
. Depending on the result, the product is then created or updated in SAP.Finally during the On Complete stage the template logs output statistics data to the console.
endpoints.xml
This file consists of two flows:
- The scheduler flow, which contains the Scheduler endpoint that periodically triggers the query flow and then executes the batch job process.
- The query flow, which contains watermarking logic that queries Salesforce for updated or created products that meet the criteria in the query since the last polling. The last invocation timestamp is stored by using the Object Store component and updated after each Salesforce query.
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.