Integrate SAP PI7.4 with SFDC(Oauth2.0)
By Rashmi Joshi, SAP PI Consultant, Yash Technologies.
This document details the steps required to enable integration between SAP ECC(On-premise) and SFDC-CRM(cloud) system, using SAP PI 7.4 middle-ware.
The business scenario is to send the quotation details from SAP ECC system to SFDC system and update the response back from SFDC to ECC. SFDC system is based on REST APIs with authentication method as OAuth2.0. To update the records on SFDC, service needs to send login request and get the access token from SFDC API. This access token needs to be updated at Header level of actual payload. With SAP PI 7.4, there is no standard adapter available to handle OAuth2.0 communication with SFDC REST APIs. Hence, used the UDF and performed REST Lookup.
Pre-requisites to start the development
- Network team needs to open port 443
- Whitelist the SFDC
- Deploy SFDC certificates SAP PI server
- Check cipher suites on SAP PI system for the compatibility
- Check the TLS version in SFDC and SAP PI
In order to maintain the length of document I am not attaching screen shots of ESR – Design objects. Below is the list of objects which I created in the ESR –
- Imported RFC for quotation from ECC system
- Receiver Data Type, Message Type
- Response Data Type, Message Type
- Inbound Service Interface – Synchronous
- Request and Response Message Mapping Programs
- In the request message mapping use the UDF code
- Operation Mapping
Provide login details at line String reqString.
Adjust below line to read the access_token key as per your service provider –
Use Dynamic configuration to create attribute Access_Token and hold the value. This will be used at receiver communication channel of ICO2.
For configuration, we need to create two ICOs. One is dummy ICO which will be used to fetch the access token from the SFDC and UDF is used to execute it. Another ICO is used to push the actual payload with header value access_token from the first ICO.
ID Objects List –
Below are the screen shots from the Integration Builder –
ICO 1 –
This is dummy ICO where we need to configure only receiver REST communication channel to fetch the access token.
Receiver rest communication channel –
Access Token URL will be provided by SFDC team.
Set the Content-Type as per URL type provided by your SFDC team. In my case it was of type –> application/x-www-form-urlencoded
ICO 2 –
For the sender side, we have used Sender RFC Communication Channel.
Provide the appropriate receiver and operation mapping details in respective tabs of ICO.
Receiver REST Communication Channel –
Provide Service Upsert URL and set the attributes of getting value from the UDF.
Set the Attribute values at the HTTP Header level –
Save and activate ID objects and interface is ready to run.
Please follow below steps to test the interface end to end –
- In ECC system, go to Tcode SE37 and provide function module name –> execute it –> provide the necessary (In my case it was quotation details) –> execute
- In PI system, go to /PIMON page –> Adapter Engine –> Message Monitoring –> You can trace the log file here
- In SFDC, search the quotation and it will be updated
If you are working on lower versions (<7.5) of SAP PI/PO and not willing to pay for OEM adapter which supports OAuth2.0. then this document will be useful to achieve integration between SAP ECC and SFDC system via SAP PI/PO system using REST adapter where SFDC APIs are oauth2.0 authenticated.