Overview
SAP is one of the most widely used ERP system in Enterprise application space. Many organizations have deployed SAP to manage their mission critical business and operation processes for many companies. While SAP is a powerful ERP system, organizations do use other specialized applications as well for their business operations. In order to fully automate and optimize these business processes, companies need to integrate SAP with other applications within their organization.
In this blog we will look into MuleSoft Integration with Salesforce and SAP (by exposing SAP CPI endpoint using OData service).
One of the most common SAP integration scenarios is MuleSoft integration between SAP and Salesforce a customer relationship management (CRM) platform available as Software as a Service (SaaS) service. Integration between SAP and Salesforce, in particular, has become a high priority requirement for many organizations, who are going through digital transformation.
Uses and benefits of SAP & Salesforce integration
Some of the benefits are listed below.
- Synchronizing master product lists between SAP and Salesforce
- Sending data for won opportunities in Salesforce to SAP for invoice creation
- When SAP and Salesforce are properly integrated, companies are able to streamline and fully automate their business processes.
Companies further benefit from SAP and Salesforce integration in the following ways:
- Elimination of the need for dual data entry, saving time and money
- Fewer data redundancies and errors caused by manual data entry
- Enhanced agility to act on new information quickly
Why MuleSoft ?
MuleSoft as an ESB is the only enterprise service bus to be certified by SAP for SAP integration. Mule’s SAP Enterprise Connector provides bidirectional communication and works with existing SAP technologies such as:
- Intermediate Documents (IDocs)
- Business Application Programming Interfaces (BAPIs)
- SAP Java Connector (JCo)
- SAP CPI endpoint using OData service
How to establish communication between SAP CPI and MuleSoft?
- ODATA message protocol over HTTP transport protocol
- HTTP message protocol over HTTP transport protocol
- SOAP message protocol over HTTP transport protocol
Use Case
To propagate ‘Case Object’ in Salesforce/Service module replication to SAP ERP system via CPI and MuleSoft.
- Whenever a ‘Case’ object is created in Salesforce service module, it generates a message to a topic using either platform events or push topic functionality.
- MuleSoft subscribes to above topic, does message transformation, and sends a message to SAP CPI in ODATA protocol.
- SAP CPI consumes the SOAP webservice hosted by SAP ERP; CPI receives message from MuleSoft, does message transformation and send to ERP.
- Propagate SAP CPI messages to Active MQ messaging system, which will be replaced with ‘SAP ERP’ in next phase.
Solution Architecture
This requirement can be simplified into three use cases, and the solution will focus more on communication between SAP CPI and MuleSoft using ODATA message protocol over HTTP transport protocol.
Whenever a ‘Case’ object is created in Salesforce service module, it generates a message to a topic using either platform events or push topic functionality. MuleSoft subscribes to above topic, does message transformation, and display the output in console
SAP CPI hosts ODATA service, upon receiving message from the client it stores it in messaging system. Will use a rest client to make a call to CPI ODATA service.
After completion of above two, will integrate both
Prerequisites:
- Subscribe to ‘SAP Cloud Platform-Cloud foundry’ trial account and provision ‘SAP cloud platform Integration’ tenant in ‘Integration service’. More details can be found from SAP’s official documentation on steps- reference link
NOTE: SAP often updates their product documentation, it’s always recommended to follow SAP’s official onboarding document.
Steps:
- Subscribe to ‘SAP Cloud Platform-Cloud foundry’ trial account.
- Subscribe to ‘Integration Suite’.
- Assign IntegrationProvisioner role to the user who is going to provision the ‘cloud platform integration’ tenant Cloud platform -> Sub account -> Security -> Trust configuration -> Click on default ‘Identity provider service’ -> Assign ‘IntegrationProvisioner’ role.
- Provision ‘SAP Cloud Platform Integration’ tenant ‘Integration service’ -> Click on ‘Go to Application’ -> Click on ‘Activate’ button.
- Create a ‘service’ user and assign ‘ESB.MessagingSend’ role to make a call to CPI Iflow endpoints.
- Subscribe to MuleSoft Any point platform trial account https://anypoint.mulesoft.com/login/signup.
- Download and install Anypoint studio, if you want build mule flow in eclipse-based IDE vs browser-based tenant. https://www.mulesoft.com/lp/dl/studio
- Subscribe to Salesforce developer trial account https://developer.salesforce.com/signup
CPI IFLOW creation steps
When you login to ‘Cloud Platform Integration’ home page, you see three tabs
Discover: To discover out of box integration packages and API’s shipped by SAP and its partners.
Design: To build integration flows
Monitor: To monitor and some other administration tasks
SAP CPI IFLOW build and deploy
- Create a package
- Design->Click on ‘Create’ button->Give ‘package name’ and ‘short description’ and click on save
- Create an IFLOW
- Click on ‘Artifacts’->Click on ‘Add’/Integration Flow->Select ‘Create’ check box->Give name of IFLOW.
ODATA adapter is used for ODATA based webservice calls.
AMQP is used for connecting to messaging system.
Configure ODATA adapter
- ODATA adapter supports ‘Role based authentication’ and ‘Certificate based authentication’ Select the ‘EDMX’ file, ‘operation’ and ‘entity set’
ODATA EDMX file:
Configure AMQP adapter to connect to messaging system (Active MQ)
- Deploying CPI IFLOW: Click on ‘Deploy’ button to deploy the IFLOW
Test CPI IFLOW from Rest client
For posting a message to ODATA service, need to fetch ‘X-CSRF-Token’ and use that token value in header to make a subsequent POST call to CPI IFLOW endpoint to send the message to SAP CPI IFLOW.
First Call:
- Second Call:
- Message posted in Active MQ server