OCRY table in SAP Business One (Countries/Regions)

OCRY is the SAP Business One table of countries and regions: one row per country code, with its name, address format, EU flag, ISO codes and the digit rules for tax IDs and bank details. Business partner addresses store the country code, so OCRY turns OCRD.Country into a readable name for sales-by-country reports.

OCRY key fields

FieldWhat it holds
CodeCountry/region code, the key. OCRD.Country points to it.
NameCountry/region name.
AddrFormatAddress format (OADF).
IsECY = EU member, N = not EU.
ISO2Code / ISO3Code / ISONumericISO alpha-2, alpha-3 and numeric codes.
TaxIdDigtsNumber of digits for the tax ID.
BnkCodDgts / BnkActDgtsNumber of digits for the bank code and the account number.
ValIbanY = validate IBAN, N = no IBAN check.
IsBlackLstY = on black list.
IsIntraSY = Intrastat transactions.
ReportCodeCode used for reports.

How OCRY relates to other tables

OCRY is master data. OCRD.Country (bill-to country) points to OCRY.Code, and so do the country columns of business partner addresses and document address details. OCRY.AddrFormat points to the address format table.

Common joins

  • OCRD T0 LEFT JOIN OCRY T1 ON T1.Code = T0.Country (bill-to country of the business partner)
  • OINV T2 INNER JOIN OCRD T0 ON T0.CardCode = T2.CardCode (invoices, then the country through OCRD)

When you use the OCRY table

Use OCRY for sales by country, to split EU and non-EU customers (IsEC), to map country codes to ISO codes for e-invoicing or EDI files, and to find business partners with no country.

Example query: customers and invoiced sales per country this year

SQL Server

SELECT T1.Code, T1.Name, T1.IsEC, COUNT(DISTINCT T0.CardCode) AS Customers,
  SUM(T2.DocTotal - T2.VatSum) AS SalesExclTax
FROM OINV T2
INNER JOIN OCRD T0 ON T0.CardCode = T2.CardCode
LEFT JOIN OCRY T1 ON T1.Code = T0.Country
WHERE T2.CANCELED = 'N' AND YEAR(T2.DocDate) = YEAR(GETDATE())
GROUP BY T1.Code, T1.Name, T1.IsEC
ORDER BY SalesExclTax DESC

SAP HANA (column names in double quotes)

SELECT T1."Code", T1."Name", T1."IsEC", COUNT(DISTINCT T0."CardCode") AS "Customers",
  SUM(T2."DocTotal" - T2."VatSum") AS "SalesExclTax"
FROM OINV T2
INNER JOIN OCRD T0 ON T0."CardCode" = T2."CardCode"
LEFT JOIN OCRY T1 ON T1."Code" = T0."Country"
WHERE T2."CANCELED" = 'N' AND YEAR(T2."DocDate") = YEAR(CURRENT_TIMESTAMP)
GROUP BY T1."Code", T1."Name", T1."IsEC"
ORDER BY "SalesExclTax" DESC

Paste either version in Tools → Queries → Query Generator. Need the other dialect for your own query? Use the SQL to HANA converter.

Common pitfall: Inner join drops partners without a country

OCRD.Country can be empty. An INNER JOIN to OCRY silently drops those business partners and their sales from a country report. Use LEFT JOIN and show an empty country as its own row, then fix the master data. See Business partners missing a tax ID query.

Ready-made queries that use OCRY

Questions about the OCRY table

How do I get the country name of a customer?

Join OCRD.Country to OCRY.Code and read OCRY.Name.

Does OCRY store ISO country codes?

Yes: ISO2Code, ISO3Code and ISONumeric.

How do I find EU countries in SAP Business One?

Filter OCRY.IsEC = 'Y'.

Related tables

OCRD (Business Partners) · OINV (A/R Invoice (header)) · search all SAP Business One tables

Sources: SAP Business One documentation and SDK (DI API database tables reference), SAP Help Portal.

Ready to get started?

Tell us what you need. You get a clear technical answer, a fixed scope and a price, usually within 24 hours.