OCRG table in SAP Business One (Business Partner Groups)
OCRG is the SAP Business One table of business partner groups: one row per customer group or vendor group, with its number, name, type and default price list. Business partners point to it through OCRD.GroupCode, so it is the table to read when a report needs sales or purchases per customer group.
OCRG key fields
| Field | What it holds |
|---|---|
GroupCode | Group number, the key. OCRD.GroupCode points to it. |
GroupName | Group name. |
GroupType | C = customer group, S = vendor group. |
Locked | Y = locked, N = not locked. |
PriceList | Price list of the group. Joins to OPLN.ListNum. |
DiscRel | Effective discount groups: L = lowest, H = highest, A = average, S = total, M = discount multiples. |
EffecPrice | Effective price: D = default priority, L = lowest price, H = highest price. |
UserSign | User who created the group. Joins to OUSR.USERID. |
DataSource | How the row was created, for example I = interface, O = DI API, S = Service Layer. |
How OCRG relates to other tables
OCRG is master data with no line table. OCRD.GroupCode points to OCRG.GroupCode, so each business partner belongs to one group. Customer groups and vendor groups share the same table and are told apart by GroupType. OCRG.PriceList points to OPLN.
Common joins
OCRD T0 INNER JOIN OCRG T1 ON T1.GroupCode = T0.GroupCode (group of the business partner)OCRG T1 LEFT JOIN OPLN T2 ON T2.ListNum = T1.PriceList (price list of the group)OINV T3 INNER JOIN OCRD T0 ON T0.CardCode = T3.CardCode (invoices, then the group through OCRD)
When you use the OCRG table
Use OCRG to report sales or purchases by customer or vendor group, to count business partners per group, and to check which price list each group uses before a pricing change.
Example query: invoiced sales per customer group this year
SQL Server
SELECT T1.GroupCode, T1.GroupName, COUNT(DISTINCT T0.CardCode) AS Customers, SUM(T3.DocTotal - T3.VatSum) AS SalesExclTax FROM OINV T3 INNER JOIN OCRD T0 ON T0.CardCode = T3.CardCode INNER JOIN OCRG T1 ON T1.GroupCode = T0.GroupCode WHERE T3.CANCELED = 'N' AND YEAR(T3.DocDate) = YEAR(GETDATE()) GROUP BY T1.GroupCode, T1.GroupName ORDER BY SalesExclTax DESC
SAP HANA (column names in double quotes)
SELECT T1."GroupCode", T1."GroupName", COUNT(DISTINCT T0."CardCode") AS "Customers", SUM(T3."DocTotal" - T3."VatSum") AS "SalesExclTax" FROM OINV T3 INNER JOIN OCRD T0 ON T0."CardCode" = T3."CardCode" INNER JOIN OCRG T1 ON T1."GroupCode" = T0."GroupCode" WHERE T3."CANCELED" = 'N' AND YEAR(T3."DocDate") = YEAR(CURRENT_TIMESTAMP) GROUP BY T1."GroupCode", T1."GroupName" 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: Mixing customer and vendor groups in one list
OCRG holds both customer groups (GroupType C) and vendor groups (GroupType S), and the numbers come from one sequence. A dropdown or report built on OCRG without a GroupType filter shows vendor groups next to customer groups. Filter GroupType = 'C' for customers and 'S' for vendors. See OCRD table (business partners).
Ready-made queries that use OCRG
- Sales by customer for a date range: Net sales per customer (invoices minus credit notes) between two dates, highest first.
- Customer balances: All customers with a non-zero account balance, with credit limit and phone.
Questions about the OCRG table
How do I get the group name of a business partner?
Join OCRD.GroupCode to OCRG.GroupCode and read OCRG.GroupName.
What does GroupType mean in OCRG?
C is a customer group and S is a vendor group. Both types live in the same table.
Can a business partner group have its own price list?
Yes. OCRG.PriceList holds the price list of the group and joins to OPLN.ListNum.
Related tables
OCRD (Business Partners) · OPLN (Price Lists) · 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.
