Official Exchange Rates into SAP with Integration Suite and ABAP: Package Guide

Set up the sap-official-exchange-rates package: a SAP Integration Suite iFlow that maps the AllRatesToday API to an EXCHANGE_RATE01 IDoc, or an ABAP report that posts with BAPI_EXCHRATE_CREATEMULTIPLE. Properties, adapter settings, backend setup, two-sided tables and tests.

By Madhushan, Founder & Lead Developer ·

The open-source sap-official-exchange-rates package loads official exchange rates (customs valuation rates by clearance country, central bank reference rates, tax authority tables) into SAP table TCURR under a rate type you choose. It has two routes. Both are reference implementations to review, test in a sandbox client and adapt. The Groovy mapping is unit-tested; the ABAP report has not been run in an SAP system by us.

RouteForFile
SAP Integration Suite (Cloud Integration)S/4HANA and ECC, on-premise or private cloud, through Cloud Connectorintegration-suite/ExchangeRateToIdoc.groovy
ABAP reportOn-premise systems that call the API directlyabap/zallrates_load_exchange_rates.prog.abap

Which endpoint to call

Send the key as Authorization: Bearer <key>. Every response carries rate_date, the authority's own table date, which both routes write as VALID_FROM.

Route 1: Integration Suite iFlow

  1. Timer start event on the source's cadence (see the schedule table).
  2. Request Reply to an HTTP receiver calling the endpoint. Keep the key in a Secure Parameter and set the Authorization header in a Content Modifier.
  3. Content Modifier setting the exchange properties below, then a Groovy Script step with ExchangeRateToIdoc.groovy.
  4. IDoc receiver adapter to the SAP system.

Script properties

PropertyMeaningDefault
RateTypeTCURR exchange rate type (KURST)M
HomeCurrencyWrite every rate as foreign → home (direct quotation)the table's own direction
CurrenciesComma list to keepall
FactorsRatios matching OBBS/TCURF, e.g. JPY:100,KRW:10001
TableRateTypeSide of a two-sided table: import or exportone row per currency, import first
SenderPort, SenderPartner, ReceiverPort, ReceiverPartnerEDI_DC40 partner data (partner type LS)none
UpdateAllowed / ChangeFixed / AllowedDeviationUPD_ALLOW / CHG_FIXED / DEV_ALLOWX / blank / 000

For the export side of India's customs table, for example:

RateType        = ZCIX          # TCURR rate type (KURST)
HomeCurrency    = INR           # write every rate as foreign -> home
Currencies      = USD,EUR,GBP   # optional filter
Factors         = JPY:100       # must match OBBS / TCURF
TableRateType   = export        # import or export, for two-sided tables
SenderPort      = SAPCPI
SenderPartner   = CPI_LS
ReceiverPort    = SAPS4H
ReceiverPartner = S4H_100

Rates are written with 5 decimals (EXCH_RATE is DEC 9,5). A rate that does not fit for the chosen factor is skipped, not truncated: give that currency a ratio in Factors and OBBS. The script also sets the headers AllRatesRateDate, AllRatesSource and AllRatesRows for monitoring.

IDoc receiver adapter

As in SAP's own exchange-rate recipe in the SAP Integration Recipes repository:

SAP backend

Route 2: ABAP report

ZALLRATES_LOAD_EXCHANGE_RATES calls the API with CL_HTTP_CLIENT, parses the response with /UI2/CL_JSON, writes every rate as foreign → home and posts with BAPI_EXCHRATE_CREATEMULTIPLE and BAPI_TRANSACTION_COMMIT.

ParameterMeaning
P_CNTRY or P_SRCClearance country (customs), or a source code such as ecb, hmrc, zollde
P_DATETable in force on this date; empty for today's table
P_HOMELedger or customs currency
P_KURSTRate type, default ZCUS
P_CURR, P_FACTOptional currency list and ratios (JPY:100)
P_RTYPTable side for two-sided tables: import or export; empty = one row per currency, import first
P_UPD, P_TESTAllow overwrite; test mode lists without posting (on by default)

Prerequisites: the SSL client PSE (STRUST) trusts allratestoday.com's certificate chain, GET_API_KEY is replaced with your secure storage, and the translation ratios exist. Schedule it in SM36 on the source's cadence, one variant per rate type.

Two-sided tables

India (CBIC), Thailand, Korea, Iceland and Uganda publish separate import and export rates per currency, and Uganda adds VAT and income-tax series. A TCURR rate type holds one rate per pair and date, so both routes keep one row per currency: the side named in TableRateType / P_RTYP, or the import side when none is named. Load each side into its own rate type, for example ZCIN with import and ZCIX with export, and assign each to the matching legal regulation in SAP GTS.

Tests

The Groovy mapping is tested with plain Groovy 4 and a stand-in for the CPI Message class:

CP="groovy-4.0.24.jar:groovy-json-4.0.24.jar:groovy-xml-4.0.24.jar"
java -cp "$CP" org.codehaus.groovy.tools.FileSystemCompiler -d build \
  test/com/sap/gateway/ip/core/customdev/util/Message.groovy
java -cp "$CP:build" groovy.ui.GroovyMain test/run.groovy   # ExchangeRateToIdoc: ok

The tests cover direction and inversion, ratios, the currency filter, skipped oversize rates, IDoc control data and the import/export selection on a two-sided table.

S/4HANA Cloud, public edition

Not covered by the package. Public edition takes exchange rates through SAP's own interfaces; check the current options and field names on the SAP Business Accelerator Hub for your release, and contact us if you need this route.

Rolling this out?

Tell us your SAP landscape and clearance countries and we will help map rate types and sources.

Talk to us View the package on GitHub