SAP Global Trade Services values a customs declaration in the currency of the clearance country, at the exchange rate that country's customs authority fixed for the declaration date. That is not the M rate your FI postings use. If GTS reads M, the customs value is off, and so is the duty.
Getting this right takes a short chain of steps in two systems: rate types in the feeder system, a scheduled load of each customs table, distribution to GTS, and an assignment in GTS customizing that tells it which rate type belongs to which legal regulation. This post walks through that chain, with the customs tables coming from the AllRatesToday customs API.
The full guide is at allratestoday.com/docs/integrations/sap-gts/.
How GTS reads exchange rates
- Rates live in table TCURR of the feeder system (S/4HANA or ECC), keyed by exchange rate type, from-currency, to-currency and valid-from date, and are distributed to GTS.
- GTS uses the exchange rate type assigned to each legal regulation in the customizing activity Control Setting for "Customs Processing" Service.
- The same settings decide whether the rate is read again at each duty calculation or fixed when first read (data element
/SAPSLL/CVRTF). - TCURR holds a valid-from date only. A rate stays in force until the next one, which is exactly how customs tables work.
1. Plan the rate types first
One customs table per rate type. The table is set by the clearance country, and in some countries by the direction of the goods:
| Case | Example rate types | Why |
|---|---|---|
| One clearance country | ZCUS |
One customs table applies. |
| Several EU member states |
ZCDE, ZCNL, ZCFR
|
Each member state sets its own monthly table; goods cleared in Rotterdam use the Dutch one. |
| Separate import and export rates |
ZCIN (import), ZCIX (export) |
India, Thailand, Korea, Iceland and Uganda fix both. Each side goes in its own type, assigned to the import or export regulation. |
| US and China |
ZCUSA, ZCCN
|
Built by rule from the Federal Reserve and CFETS series; responses say "method": "rule" with the rule in basis. |
The names are examples; use your own naming standard. GET /api/v1/customs (no key needed) lists which authority covers each country.
2. Create the rate types and ratios
- Define each rate type in the feeder system (transaction
OB07). - Maintain the translation ratio for every currency pair in the type (transaction
OBBS, tableTCURF).
The ratios matter more than they look. EXCH_RATE is DEC 9,5, so a rate above 9,999.99999 for one unit doesn't fit. Currencies with large unit values (JPY, KRW, IDR, VND and similar) usually need 100 or 1,000. Without the ratio, both the load and the transfer to GTS fail with a message asking you to maintain the translation ratios.
3. Load the customs tables on schedule
There are three ways in, all writing the same TCURR rows: an Integration Suite iFlow that maps the API response to an EXCHANGE_RATE01 IDoc, the ABAP report ZALLRATES_LOAD_EXCHANGE_RATES scheduled in SM36 (both in the SAP package), or RFC from a script. Here's the script route with Python and pyrfc:
import requests
from pyrfc import Connection
API = "https://allratestoday.com/api/v1/customs"
HEADERS = {"Authorization": "Bearer art_live_your_key"}
PREF = ["reference", "mid", "import", "buy", "sell", "export"] # the API's own order
def customs_rows(country, home_ccy, rate_type, side=None, factors=None, date="latest"):
"""TCURR rows (foreign -> home) for one customs rate type."""
factors = factors or {}
t = requests.get(f"{API}/{country}/{date}", headers=HEADERS, timeout=10).json()
rates = [r for r in t["rates"] if side is None or r["type"] == side]
rates.sort(key=lambda r: PREF.index(r["type"]) if r["type"] in PREF else 99)
seen, rows = set(), []
for r in rates:
if r["quote"] == home_ccy:
ccy, v = r["base"], r["value"]
elif r["base"] == home_ccy:
ccy, v = r["quote"], 1 / r["value"]
else:
continue
if ccy in seen: # one side per currency per rate type
continue
seen.add(ccy)
f = factors.get(ccy, 1)
rows.append({"RATE_TYPE": rate_type, "FROM_CURR": ccy, "TO_CURRNCY": home_ccy,
"VALID_FROM": t["rate_date"].replace("-", ""),
"EXCH_RATE": round(v * f, 5), "FROM_FACTOR": f, "TO_FACTOR": 1})
return t, rows
conn = Connection(ashost="erp.example.com", sysnr="00", client="100", user="RFCUSER", passwd="...")
for country, home, kurst, side in [("NL", "EUR", "ZCNL", None), ("DE", "EUR", "ZCDE", None),
("IN", "INR", "ZCIN", "import"), ("IN", "INR", "ZCIX", "export")]:
t, rows = customs_rows(country, home, kurst, side, factors={"JPY": 100, "KRW": 1000})
res = conn.call("BAPI_EXCHRATE_CREATEMULTIPLE", EXCHRATE_LIST=rows, UPD_ALLOW="X")
if any(m["TYPE"] in ("E", "A") for m in res["RETURN"]):
raise SystemExit((country, kurst, res["RETURN"]))
conn.call("BAPI_TRANSACTION_COMMIT", WAIT="X")
print(country, kurst, t["authority"]["code"], t["rate_date"], len(rows))
Two rules every route follows:
-
VALID_FROMis the table'srate_date, not the run date. -
A two-sided table gives one row per currency per rate type, the side you ask for. Loading both sides into one type would leave whichever row was posted last. That's why India appears twice in the loop, once per side, into
ZCINandZCIX.
Schedule by cadence
Customs tables don't all change daily, so match the job to the table:
| Cadence | Examples | When to run |
|---|---|---|
| Monthly | EU member states (Art. 146 tables), China, Thailand, Uganda | Where the table is set early (EU, China): last days of the previous month with /next (paid plans). Otherwise on the 1st with /latest
|
| Fortnightly | India (CBIC) | Daily check; a notification takes effect the day after it is issued |
| Weekly | Japan, Korea, Iceland, Indonesia | Before the week starts |
| Daily | Canada, Australia, South Africa, Switzerland | Every evening or early morning |
Running more often than needed is harmless: with UPD_ALLOW set, a rerun rewrites the same date.
4. Distribute the rates to GTS
Use the standard route: report RFALEX00 distributes message type EXCHANGE_RATE over ALE to the GTS system. Set up the RFC destination, distribution model, port and partner profiles as for any ALE scenario, restrict the distribution to your customs rate types, and schedule it right after the load job.
5. Assign the rate types to the legal regulations
In GTS customizing, Control Setting for "Customs Processing" Service, assign each customs rate type to the legal regulation for its clearance country, and the export rate type to the export regulation where the country has one. Decide there whether the rate is fixed at first read or read again at each duty calculation. Menu paths differ between GTS 11.0 and SAP GTS, edition for SAP HANA, so check the activity names in your release.
6. Check the result
After the first load, compare a few TCURR entries (OB08 or SE16) with the official table, then follow one test declaration through GTS. A small helper for the comparison:
# After the load: compare what TCURR holds with the official table for a date
def check(country, date, ccy, home_ccy, tcurr_rate, factor=1, side=None):
params = {"source": ccy, "target": home_ccy}
if side:
params["type"] = side
r = requests.get(f"{API}/{country}/{date}", params=params, headers=HEADERS, timeout=10).json()
return abs(tcurr_rate / factor - r["rate"]) / r["rate"] < 1e-5, r["rate"], r["rate_date"]
For the audit trail, log each load (clearance country, authority code, rate_date, rate type, row count), keep derived and method for pairs the authority didn't print and basis for rule-built tables. A past declaration can be re-checked any time: /api/v1/customs/{country}/{date} returns the table in force on that date.
Troubleshooting
-
"Maintain the translation ratios": a pair in the rate type has no
OBBSentry. Add it with the same factor the load uses. -
A currency is missing after the load: its rate didn't fit DEC 9,5 for one unit. Give it a ratio of 100 or 1,000 in both
OBBSand the load. -
IDoc in status 56: the sender port, partner or partner type in the IDoc control record doesn't match the inbound partner profile (
WE20). -
The export declaration shows the import rate: the export regulation points at the import rate type, or the export type was loaded without the
exportside. -
A new month's EU rate is missing on the 1st: the load ran before the table existed. Use
/nextat month end or rerun on the 1st.
Links
- Guide: https://allratestoday.com/docs/integrations/sap-gts/
- Covered banks and tax authorities: https://allratestoday.com/central-bank-rates-api/institutions/
- Other integrations (SAP TCURR, SAP package, Business Central, Xero, Odoo): https://allratestoday.com/docs/integrations/
- API key: https://allratestoday.com/register/
Rates are redistributed from each institution's own publication. They are reference rates for accounting, tax and compliance, not dealing quotes.
Top comments (0)