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:
Mandatory Fields
sourceCurrency– currency to convert FromtargetCurrency– currency to convert TosourceAmount– amount to be converted
NOTE:
If even one is missing, the message is rejected immediately and routed to the Exception Subprocess.
High‑Level Architecture
The integration flow consists of:
- HTTPS Sender – receives the request
- Content Modifier – stores RapidAPI host and key securely
- Groovy Script – validates input and extracts fields
- Request Reply – calls external exchange‑rate API
- JSON to XML Converter – prepares response for XSLT
- XSLT Mapping – beautifies output into HTML
- Mail Adapter – sends result to user
- 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.
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
- Credentials are easy to change
- Scripts remain clean
- No risk of accidentally logging secrets
STEP 3: Groovy Script – Input Extraction & Validation
The Groovy script performs hard validation for the incoming payload.
Here is the Groovy Script:
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
The Request Reply step dynamically calls the external RapidAPI Currency Exchange endpoint using:
- Source currency
- Target currency
- Secure headers from the Content Modifier
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.
-
Mapping easier
-
Formatting predictable
- Transformation logic much cleaner
STEP 6: XSLT Mapping – Beautified HTML Output
Here is the XSLT Script:
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
STEP 8: Exception Subprocess – For Error Handling
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
Here what the Error Mail Adapter does:
- Send a structured and well formatted HTML error email, just like as for success mail
Success Email Output:
- Gives successful currency conversion information dynamically
Error Email Output:
- Gives Error message and its possible causes in case of any error
Key benefits of this approach
- Robust mandatory field validation
- Secure credential handling
- Professional, email‑ready output
- User‑friendly error messages
- Reusable iFlow pattern for other APIs
- 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