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 Participant

As we've discussed on the previous Blog, SAP® “speaks” OData (Mobile, FIORI, etc.), so my goal here again is to demonstrate how the “OData conversion” works on CPI, creating a simple Calculator (multiply operation) iFlow:

Please go through the previous blog here.

We have a few options as the data source on the OData iFlow creation, this time i’m gonna use the REST one (in the same OData service created on the previous blog).

For this tutorial, we're using the API. It's really simple, if you want to multiply 2 numbers, just do it like these:*2 and will return the result on plain text on your browser.

So let's get to it, open the scenario created on the previous blog and let's edit the OData Model Editor:

To create the selected lines. We're basically creating a new Entity called MultiplyREST (with 3 fields as well, REST1, REST2 and RESTResult).

In the end it should look like these:
xmlns:sap="" Version="1.0">
xmlns:m="" m:DataServiceVersion="2.0">
xmlns="" Namespace="S1">
<EntityContainer Name="EC1" m:IsDefaultEntityContainer="true">
<EntitySet Name="MultiplySOAPSet" EntityType="S1.MultiplySOAP"></EntitySet>
<EntitySet Name="MultiplyRESTSet" EntityType="S1.MultiplyREST"></EntitySet>
<EntityType Name="MultiplySOAP">
<PropertyRef Name="SOAP1"></PropertyRef>
<Property Name="SOAP1" Type="Edm.String" Nullable="false"></Property>
<Property Name="SOAP2" Type="Edm.String" Nullable="true"></Property>
<Property Name="SOAPResult" Type="Edm.String" Nullable="true"></Property>
<EntityType Name="MultiplyREST">
<PropertyRef Name="REST1"></PropertyRef>
<Property Name="REST1" Type="Edm.String" Nullable="false"></Property>
<Property Name="REST2" Type="Edm.String" Nullable="true"></Property>
<Property Name="RESTResult" Type="Edm.String" Nullable="true"></Property>

Switching back, change the new Entity to a REST data source:

And create a Bind for the Create operation as well. It creates a iFlow for your, but we're doing some minor changes to it, in the end it should look like these:

First, let's delete the first script and place a Content Modifier:

In there we're creating properties for the 2 input fields (using XPath), as we need them to execute the Multiply operation in the API URL.

In the HTTP Request-Reply operation, the URL will look like these:${property.REST1}*${property.REST2}

Don't forget to change the call to GET and the Auth to None.

On the Response Mapping Groovy Script, insert the code below:
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(;
def string = message.getBody(java.lang.String);
map = message.getProperties();
REST1 = map.get("REST1");
REST2 = map.get("REST2");
"<MultiplyRESTSet>" +
"<MultiplyREST>" +
"<REST1>" + REST1 + "</REST1>" +
"<REST2>" + REST2 + "</REST2>" +
"<RESTResult>" + string + "</RESTResult>" +
"</MultiplyREST>" +
return message;

We're basically getting the response as String, also the 2 input fields from the request(Property), and creating a Entity Set response with the data on the desired format.

Save and deploy your iFlow. Now, let's test it:

First, don’t forget to get the Token(X-CSRF-Token) from a simple Get to the OData root URL service. After that, let’s make a POST request using the payload below:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="" xmlns:m="" xmlns:d="">
<content type="application/xml">

And Voilà:

Play around as you want!


Labels in this area