Step-by-Step Guide: Real Time Currency Conversion using SAP Integration Suite (CPI)
Share

Introduction

In real-world integration scenarios, integrations are never limited to just data movement. Very often, they also involve business logic that needs to be accurate, reliable, and understandable for non‑technical users. One such recurring requirement encounters is currency conversion.

Whether it’s for reporting, billing, or analytics, converting currency values accurately and in real time is an important requirement.

In this blog, I will be sharing a real‑time currency conversion iFlow that I designed and implemented using SAP Integration Suite (CPI). This solution uses an external currency exchange‑rate API (RapidAPI) and delivers the result in a clean, email‑friendly output, along with robust exception handling.


Business Scenario

The scenario is straightforward but very realistic:

  • A source system sends an amount in one currency
  • A target system expects the amount in another currency
  • The exchange rate must be live and reliable
  • The final output should be human‑readable and user friendly, not just raw JSON

At the same time, the integration should not break silently when:

  • Mandatory fields are missing
  • The input payload is malformed
  • The external API is down
  • Any runtime exception occurs

This Integration scenario strictly follows all the mentioned points and ensures that it give accurate results and handle errors efficiently.


Input Payload (Source System to CPI)

The source system (ie, Postman) sends a simple JSON payload:

Screenshot 2026-03-31 at 3.05.12 PM.png

Mandatory Fields

  • sourceCurrency – currency to convert From
  • targetCurrency – currency to convert To
  • sourceAmount – amount to be converted

NOTE:

I have made a conscious decision to treat all three as mandatory.
If even one is missing, the message is rejected immediately and routed to the Exception Subprocess.

High‑Level Architecture

Screenshot 2026-03-31 at 12.04.37 AM.png

The integration flow consists of:

  1. HTTPS Sender – receives the request 
  2. Content Modifier – stores RapidAPI host and key securely 
  3. Groovy Script – validates input and extracts fields 
  4. Request Reply – calls external exchange‑rate API 
  5. JSON to XML Converter – prepares response for XSLT  
  6. XSLT Mapping – beautifies output into HTML 
  7. Mail Adapter – sends result to user 
  8. Exception Subprocess – handles all runtime failures

STEP 1: HTTPS Sender – Entry Point of the Integration Flow

The integration flow begins with an HTTPS Sender Adapter, which acts as the entry point for the entire currency conversion process.

Screenshot 2026-03-31 at 2.54.30 PM.pngScreenshot 2026-03-31 at 2.55.00 PM.png

Purpose of HTTPS Sender

  • Exposes the iFlow as a secure REST endpoint
  • Receives the input JSON payload from the source system (Postman)
  • Secure by default and commonly used in real projects for inbound APIs

STEP 2: Content Modifier – Managing API Credentials

Instead of hard‑coding the RapidAPI host and key inside a Groovy script, I stored them as headers in a Content ModifierIt makes the integration much more maintainable.
  • Credentials are easy to change
  • Scripts remain clean
  • No risk of accidentally logging secrets

Screenshot 2026-03-31 at 2.38.36 PM.pngScreenshot 2026-03-31 at 2.40.07 PM.png


STEP 3: Groovy Script – Input Extraction & Validation

The Groovy script performs hard validation for the incoming payload.

Screenshot 2026-03-31 at 1.52.54 PM.png

Here is the Groovy Script:

Screenshot 2026-03-31 at 1.54.04 PM.png

 So in this Groovy script, I have :

  • Parsed the JSON explicitly
  • Checked each mandatory field
  • Stored valid values as Exchange Properties
  • Throws a meaningful exception if any field is missing

This hard validation is crucial because CPI does not throw errors for missing JSON fields by default.

Because of this, invalid messages are stopped immediately and routed to the Exception Subprocess 


STEP 4: Request Reply – Calling the Exchange Rate API

Screenshot 2026-03-31 at 1.45.31 PM.png

The Request Reply step dynamically calls the external RapidAPI Currency Exchange endpoint using:

  • Source currency
  • Target currency
  • Secure headers from the Content Modifier

Screenshot 2026-03-31 at 1.44.13 PM.png

And If the API:

  • Times out
  • Returns an error
  • Is unreachable

Exception Subprocess handles the failure gracefully.


STEP 5: JSON to XML Converter

Since XSLT only works with XML, so i converted the API’s JSON response into XML.

Screenshot 2026-03-31 at 1.36.44 PM.png

Screenshot 2026-03-31 at 1.39.19 PM.png

This made:
  • Mapping easier
  • Formatting predictable
  • Transformation logic much cleaner

STEP 6: XSLT Mapping – Beautified HTML Output

Screenshot 2026-03-31 at 1.50.52 AM.png

Here is the XSLT Script:

Screenshot 2026-03-31 at 12.24.29 AM.pngScreenshot 2026-03-31 at 1.44.28 AM.pngScreenshot 2026-03-31 at 1.44.47 AM.png

 
Instead of returning raw API data in JSON, I used XSLT to generate a beautiful modern HTML card, optimized for email clients.

Features that i have focused for beautification includes:

  • A green glowing success card 
  • Currency symbols 
  • Proper decimal formatting 
  • Email‑safe inline CSS 
  • Readable and user friendly

STEP 7: Mail Adapter – Delivering the Result

The Mail Adapter sends:

  • The formatted HTML
  • Clean layout
  • No broken styling
  • Compatible with Outlook, Gmail, mobile clients

Screenshot 2026-03-31 at 2.12.41 AM.png

Screenshot 2026-03-31 at 2.15.58 AM.pngScreenshot 2026-03-31 at 2.18.15 AM.png


STEP 8: Exception Subprocess – For Error Handling

 

Screenshot 2026-03-31 at 2.29.54 AM.png

The Exception Subprocess ensures there are no silent failures and handles errors effectively.

Here’s what the Groovy script does:

  • Captures runtime errors
  • Identifies what actually went wrong
  • Categorizes the error:
    • Missing mandatory fields
    • Malformed JSON
    • External API failure
    • Script execution error
  • Generates modern card formation using HTML for Beautification 

Screenshot 2026-03-31 at 2.35.47 AM.pngScreenshot 2026-03-31 at 2.36.15 AM.png

Here what the Error Mail Adapter does:

  • Send a structured and well formatted HTML error email, just like as for success mail

Screenshot 2026-03-31 at 1.19.49 PM.pngScreenshot 2026-03-31 at 1.20.27 PM.png


Success Email Output:

  • Gives successful currency conversion information dynamically

Media (8).jpeg


Error Email Output:

  • Gives Error message and its possible causes in case of any error

Media (9).jpeg


Key benefits of this approach 

  1. Robust mandatory field validation
  2. Secure credential handling
  3. Professional, email‑ready output
  4. User‑friendly error messages
  5. Reusable iFlow pattern for other APIs
  6. Fully Externalized Parameters 

Conclusion

This currency conversion iFlow shows how SAP Integration Suite can be used for much more than just routing messages.

I was able to build an integration that is stable, readable, and production‑ready.

This implementation helped me better understand how to design flexible and maintainable integration flows, especially when dealing with real-world requirements.

I hope this experience helps others who are working on similar scenarios in SAP Cloud Integration.

If you found this blog helpful:

  • Like the blog
  • Share it 
  • Feel free to comment or ask questions

Happy Integrating !

 

  Read More Technology Blog Posts by Members articles 

#abap

By ali