Skip to Content
Technical Articles
Author's profile photo Priyanka Chakraborti

SAP Cloud Integration with Salesforce – Part 2

Introduction:

In this blog post, I will explain how to use the composite API in Salesforce using a case replication scenario.

Prerequisite:

Go through blog post SAP Cloud Integration with Salesforce – Part 1 to understand the scenario, prerequisite setup and previous design solution.

What is Composite API?

It executes a series of REST API requests in a single call. The output of one request is used as the input for subsequent requests.

Help Link: Composite API

Design Solution in Cloud Integration:

Integration%20Flow

Integration Flow

Step 1:

Configure Sender Channel as below.

HTTPS%20Sender%20Channel

HTTPS Sender Channel

Step 2:

Call Local Integration Process via Process Call.

Step 2.a:

Convert incoming JSON message to XML using JSON to XML Converter.

Step 2.b:

Use Message Mapping to map the input structure to composite API XSD structure. The XSD structure for sObject can be downloaded from the Eclipse pluginSalesforce Adapter Workbench. Select the following sObjects, Account, Contact and Case for creating the XSD structure (as shown below).

XSD%20Generator

XSD Generator

Message%20Mapping

Message Mapping

Parameter ‘allOrNone’

Set it as true. It is used to specify what to do when an error occurs while processing a sub-request. If this flag is set as ‘true’, the entire request is rolled back. If it is set as ‘false’, the remaining sub-requests that don’t depend on the failed sub-requests are executed.

Sub-Request for Account

Sub%20Request%20for%20Account

Sub-Request for Account

It is used to get AccountId from Salesforce based on input AccountNo.

Mapping%20Rule%20for%20Account%20Sub%20Request

Mapping Rule for Account Sub-Request

Sub-Request for Contact

It is used to get ContactId from Salesforce based on input RequestorEmail.

Mapping%20Rule%20for%20Contact%20Sub%20Request

Mapping Rule for Contact Sub-Request

Sub-Request for Case

The value of AccountId and ContactId are retrieved from the output of previous sub-requests.

Mapping%20Rule%20for%20Case%20Sub-Request

Mapping Rule for Case Sub-Request

Step 2.c:

Use Request Reply step to send data to Salesforce.

Receiver%20Salesforce%20Adapter

Receiver Salesforce Adapter

Step 2.d:

Use Router to determine if the case object is created or not.

Router

Router

Step 2.e:

Use Content Modifier to prepare a response body for the success route.

Response%20Payload%20for%20Success%20Route

Response Payload for Success Route

Step 2.e’:

Use Content Modifier to prepare a response body for the failure route.

Response%20Payload%20for%20Failure%20Route

Response Payload for Failure Route

Test Execution:

Test Case 1: Success Scenario

Response%20Received%20from%20Salesforce

Response Received from Salesforce

Test Case 2: Failure Scenario

Response%20Received%20from%20Salesforce

Response Received from Salesforce

Conclusion:

  1. Composite API reduces the number of round-trips between SAP Cloud Integration and Salesforce.
  2. In a sub-request, a reference ID is specified that maps to the sub-request’s response. The ID can be referred in the later sub-requests.
  3. An error in a sub-request causes either the whole composite request to roll back or the dependent sub-requests to roll back, which can be configured.

Thank you for reading this blog post. Please feel free to share your feedback or thoughts or ask questions in the Q&A tag below.

QA link

Regards,

Priyanka Chakraborti

 

Previous – Part 1 | Next – Part 3

 

 

 

 

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo subhash Reddy
      subhash Reddy

      Hi, I need to learn CPI.... Please guide me.....9966582557

       

      Author's profile photo Priyanka Chakraborti
      Priyanka Chakraborti
      Blog Post Author

      Hi Subhash,

      To start with CPI, you can start with the below tutorial.

      https://developers.sap.com/tutorials/cp-starter-integration-cpi-design-iflow.html

      In case of any queries, you can ask your question in QA tag.

      QA link

      Regards,

      Priyanka

      Author's profile photo subhash Reddy
      subhash Reddy

      If possible, please teach me..... I need very urgently for  Current project is in CPI

      Author's profile photo Paul Mckleinson
      Paul Mckleinson

      You put really very helpful information!

      Author's profile photo Priyanka Chakraborti
      Priyanka Chakraborti
      Blog Post Author

      Thanks 🙂

      Author's profile photo Anish Shah
      Anish Shah

      Very nice explanation, really helpful.

      Author's profile photo Priyanka Chakraborti
      Priyanka Chakraborti
      Blog Post Author

      Thanks 🙂

      Author's profile photo Souymodip Chakraborty
      Souymodip Chakraborty

      Thanks for sharing.