OSTC table in SAP Business One (Sales Tax Codes)

OSTC is the SAP Business One table of sales tax codes: one row per tax code with its name, combined rate, whether it is valid for sales (A/R) and purchasing (A/P), and an inactive flag. Document lines store it in TaxCode and business partners in OCRD.VatGroup, so OSTC gives the rate and name behind sales tax reports.

OSTC key fields

FieldWhat it holds
CodeSales tax code, the key. INV1.TaxCode and JDT1.TaxCode point to it.
NameTax code name.
RateRate.
ValidForARY = valid for A/R documents.
ValidForAPY = valid for A/P documents.
FreightY = freight.
LockY = inactive, N = active.
TfcIdFormula combination ID (OTFC).
IsSystemY = system tax code.
EfctDateEffective from date.
VatExemptY = apply VAT exemption.
ProviderTax service provider.

How OSTC relates to other tables

OSTC is master data. Document lines carry TaxCode (INV1.TaxCode and the other line tables), journal entry lines carry JDT1.TaxCode, and OCRD.VatGroup holds the default tax code of a business partner, all pointing to OSTC.Code. Tax definitions of VAT-based setups are in OVTG instead.

Common joins

  • INV1 T0 INNER JOIN OSTC T1 ON T1.Code = T0.TaxCode (tax code of the invoice line)
  • JDT1 T2 INNER JOIN OSTC T1 ON T1.Code = T2.TaxCode (tax code of the journal line)
  • OCRD T3 LEFT JOIN OSTC T1 ON T1.Code = T3.VatGroup (default tax code of the business partner)

When you use the OSTC table

Use OSTC to total taxable sales and tax per tax code, to list the codes valid for sales or purchasing, and to find customers whose default tax code is inactive.

Example query: taxable sales and tax per sales tax code this month

SQL Server

SELECT T1.Code, T1.Name, T1.Rate, SUM(T0.LineTotal) AS NetAmount, SUM(T0.VatSum) AS TaxAmount
FROM INV1 T0
INNER JOIN OINV T2 ON T2.DocEntry = T0.DocEntry
INNER JOIN OSTC T1 ON T1.Code = T0.TaxCode
WHERE T2.CANCELED = 'N' AND T2.DocDate >= DATEADD(day, 1 - DAY(GETDATE()), CAST(GETDATE() AS date))
GROUP BY T1.Code, T1.Name, T1.Rate
ORDER BY T1.Code

SAP HANA (column names in double quotes)

SELECT T1."Code", T1."Name", T1."Rate", SUM(T0."LineTotal") AS "NetAmount", SUM(T0."VatSum") AS "TaxAmount"
FROM INV1 T0
INNER JOIN OINV T2 ON T2."DocEntry" = T0."DocEntry"
INNER JOIN OSTC T1 ON T1."Code" = T0."TaxCode"
WHERE T2."CANCELED" = 'N' AND T2."DocDate" >= ADD_DAYS(CAST(CURRENT_TIMESTAMP AS date), 1 - DAYOFMONTH(CURRENT_TIMESTAMP))
GROUP BY T1."Code", T1."Name", T1."Rate"
ORDER BY T1."Code"

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

Common pitfall: OCRD.VatGroup is a tax code, not a VAT group

Despite its name, OCRD.VatGroup points to OSTC (sales tax codes), while OCRD.ECVatGroup points to OVTG. On document and journal lines it is the other way round: TaxCode goes to OSTC and VatGroup to OVTG. Check which column your localization fills before you join. See OVTG table (tax groups).

Questions about the OSTC table

Which line column points to OSTC?

TaxCode, for example INV1.TaxCode and JDT1.TaxCode.

How do I find tax codes valid for purchasing?

Filter OSTC.ValidForAP = 'Y'; ValidForAR does the same for sales.

How is an inactive sales tax code marked?

OSTC.Lock = 'Y' means inactive.

Related tables

OVTG (Tax Definitions (VAT groups)) · INV1 (A/R Invoice (lines)) · JDT1 (Journal Entry Lines) · OCRD (Business Partners) · 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.