Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
Showing results for 
Search instead for 
Did you mean: 
Active Contributor
Hello Folks,

Everything is a cloud? 🙂

So basically I did a compilation of brilliant blog of mandy.krimmelRetry JMS CPI - and blog of sidharthramasamy  - Open Connector - CPI - Part 1Open Connector - CPI - Part 2

One project requirement for SAP CPI was the exception in case the Third Party system is with different windows for maintenance or something else different from the source SAP system.

I developed without using the OpenConnector (oAth2) just simple POST in the ServiceNow API - HTTPS.

The integration is HTTPS to HTTPS without data transformation - Pass Thought CPI.

First Interface Diagram:


Second Interface Diagram:

First Integration Flow:

Integration Flow Description:

  • Sender

  • Exception flow

  • Sender

  • Content Modifier

  • Content Modifier - Response HTTPs

  • End of Event/Exception.

  • Receiver

  • Exception flow

In case of failure in the communication with the Third Party system under HTTPS Call - Basic Authentication.

  • Sender

Send the message to JMS Queue.

  • Content Modifier -  Get Tenant full address:

Creating a header "url" - from Camel expression: ${header.CamelDestinationOverrideUrl}

  • Response HTTPs

Text message for the sender system with some Camel expression details as Date and Tenant Number:

Date: ${date:now:dd-MM-yyyy HH:mm z} 

Tenant Number: ${header.url.substring(8,15)}

Name of the queue: RetryMessageQueue - Reference for the support team proceed with manual retry.
Hello Team,

There is an error to invoke SAP ICH system - Error detail: connection timed out:

Date: 08-02-2020 19:03 GMT / SAP CPI - Tenant Number: lXXXXXX

The message will be stored at the queue name: RetryMessageQueue

The process will try to retry the message 3 times, after this period in case of the issue to invoke SAP ICH system, the incident will be open in ServiceNow.

Thanks for your attention,


Basically the first integration flow it's HTTPS outbound in case of exception to delivery the message to the Third Party system it's offline, the message should be stored in JMS Queue internal of SAP CPI then content modifier to get the name of Tenant System Hostname and another content modifier to create the exception message with detail to return to sender system - SAP.

Second Integration Flow:

The second integration flow process the message from JMS (read), try to send and retry in case of fail with the third party system and in case of fail of retry mechanism the incident will be created in ServiceNow - Incident Management Platform.

Integration Flow and description:

  • Sender - JMS

  • Exception

  • Call Retry Mechanism - Local Integration Process.

  • Retry Call Logic

  • Stuck the message in the queue for manual reprocess by the support team.

  • Groovy Script (Logging)

  • Groovy Script (Get Dynamic Name from the XML file)

  • Content Modifier - XML - Create the incident ticket

  • XML to JSON - Function.

  • Groovy Script (Logging)

  • End of Event/Exception.

  • Open Ticket Service Now

  • Receiver

Flow CPI:

  • Exception

In case of failure in the communication with the Third Party system under HTTPS Call - Basic Authentication.

  • Call Retry Mechanism - Local Integration Process:

Create a local process with a router default way and no expression type:

${header.SAPJMSRetries} > '3' - 3 times just for the test - but you can add how many you need.

You can extract this header detail acting the trace log.

Local Flow:

Retry Details:

  • Stuck the message in the queue for manual reprocess by the support team.

After failing the local retry mechanism based on the header parameter - SAPJMSRetries, the message will be stuck in the QUEUE Monitoring (Manage Message Queues) in the image below it's already the last retry - 3.

Manage Stores: Message Queues

Message Queues Details:

  • Groovy Script (Logging):

Storing the original message from the sender system as attachments in the log system.
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
def messageLog = messageLogFactory.getMessageLog(message);
if(messageLog != null){
messageLog.setStringProperty("Logging#1", "ServiceNow2")
messageLog.addAttachmentAsString("The original XML from Sender System:", body, "text/plain");
return message;

  • Groovy Script (Get Dynamic Name from the XML file):

Reading the XML and extracting the value from tag 'Sender' - I know that it's not the best because of reading the whole XML but this was just for the POC perspective.
import java.util.HashMap;
import groovy.util.XmlSlurper;
def Message processData(Message message) {
def body = message.getBody(String.class);
def completeXml = new XmlSlurper().parseText(body);
def GLN = completeXml.'**'.find{ node-> == 'Sender'}.text();
return message;

  • Content Modifier - XML - Create the incident ticket:

Basically, to be easier to build and use others functions to change XML to JSON, I decide to create this content modifier with the body:
<?xml version="1.0" encoding="UTF-8"?>
<assigned_to>Ricardo Viana</assigned_to>
<assignment_group>TEST POC - SERVICE NOW</assignment_group>
<caller_id>CPI Support Team</caller_id>
<description>**- There is an issue running to delivery message to SAP ICH system -**
1) Overview.
2) Manage Stores.
3) Message Queues
4) Check the queue name: Retry MessageQueue.
5) Contact the responsable person in the SAP ICH System
6) After receive the confirmation of the system ON-LINE
7) Click at Retry Button to restart the stuck messages in CPI.</description>
<short_description> POC BLOG SAP - GLN: ${property.GLN} ATTP Project</short_description>

The value property.GLN it's set up via the previous groovy script.

  • XML to JSON - Function:

Suppress the root of the message because the API JSON does not expect.

  • Groovy Script (Logging):

Basically the same groovy above but with some different parameters just to save the incident ticket details in JSON.

Groovy of ServiceNow Ticket and the original XML file from the sender system.

  • Open Ticket Service Now:

Ticket open with the details provided from the JSON message.

Short Description of Incident comes:

<short_description> POC BLOG SAP - GLN: ${property.GLN} ATTP Project</short_description>

An interesting topic is you can define Priority direct in the message built by CPI in JSON format or if you want you can use the value mapping table to determine the priority of each flow in your landscape.

Generic Value Mapping Table details:

Based on the value mapping you dynamic generate the message JSON to ServiceNow.

I hope that you understand the topic because CPI does not is PI with retry and store mechanisms default.

Nice time.

Kind Regards,




Labels in this area