The SAP Business One supplier analysis is one of the most common blind spots in companies that have already implemented the ERP but still don't exploit its data. They know how much they sell, but they don't really know who they buy from, on what terms or with what level of reliability. The purchasing module generates hundreds of documents a month; yet without the right queries, all that information stays buried in the database tables.
In this tutorial you'll learn to extract, organize and analyze purchasing and supplier information directly from SAP Business One using SQL. By the end, you'll have a set of queries ready to run in the Query Manager that let you make decisions based on real data, not on past impressions.

Why SAP Business One supplier analysis is strategic
Without structured purchasing analysis, companies decide by inertia: they keep buying from the same supplier because «it has always worked», without knowing whether cheaper or more reliable alternatives exist. On top of that, they fail to catch suppliers who miss delivery dates in time, which causes stockouts and production stoppages that were entirely avoidable.
So the first step to optimizing your supply chain is knowing exactly how your suppliers actually behave. SAP Business One stores all of this in its transactional tables: purchase orders (OPOR/POR1), goods receipts (OPDN/PDN1) and supplier invoices (OPCH/PCH1). The key is knowing how to combine them to extract actionable business intelligence.
Prerequisites before running the queries
Before you begin, make sure you have the following in your SAP Business One environment:
- Access to the Query Manager (Tools → Queries → Query Manager)
- Read permissions on the Purchasing and Business Partners modules
- Knowing whether your instance runs on SQL Server o SAP HANA so you can pick the right version of each query
- At least 3 months of purchasing data loaded in the system so the results are statistically representative
Main tables of the purchasing module in SAP B1
First of all, it's essential to know the tables you're going to query. Here are the most important ones in the SAP Business One purchasing module:
- OPOR / POR1: Header and lines of Purchase Orders
- OPDN / PDN1: Header and lines of Goods Receipts (Goods Receipt PO)
- OPCH / PCH1: Header and lines of Supplier Invoices (A/P Invoice)
- OCRD / OCRG: Business Partners and their Groups
- OITM / OITB: Items and Item Groups
Query 1: Top suppliers by purchase amount
First, you need to know who you're buying from and how much. This query groups approved supplier invoices and sorts them by total amount. As a result, you'll be able to identify your concentration of critical suppliers and start negotiations based on real volume, not estimates.
SQL Server
-- Top suppliers by purchase amount (SQL Server)
-- Tables: OPCH (A/P Invoices), OCRD, OCRG
SELECT TOP 20
T0.CardCode AS [Supplier Code],
T0.CardName AS [Supplier Name],
T1.GroupName AS [Group],
COUNT(T0.DocEntry) AS [Invoice Count],
SUM(T0.DocTotal) AS [Total Purchased],
AVG(T0.DocTotal) AS [Average Ticket],
MAX(T0.DocDate) AS [Last Purchase]
FROM OPCH T0
INNER JOIN OCRD T2 ON T2.CardCode = T0.CardCode
LEFT JOIN OCRG T1 ON T1.GroupCode = T2.GroupCode
WHERE T0.DocDate BETWEEN DATEADD(MONTH, -12, GETDATE()) AND GETDATE()
AND T0.CANCELED = 'N'
GROUP BY T0.CardCode, T0.CardName, T1.GroupName
ORDER BY SUM(T0.DocTotal) DESCSAP HANA
-- Top suppliers by purchase amount (SAP HANA)
SELECT TOP 20
T0."CardCode" AS "Supplier Code",
T0."CardName" AS "Supplier Name",
T1."GroupName" AS "Group",
COUNT(T0."DocEntry") AS "Invoice Count",
SUM(T0."DocTotal") AS "Total Purchased",
AVG(T0."DocTotal") AS "Average Ticket",
MAX(T0."DocDate") AS "Last Purchase"
FROM OPCH T0
INNER JOIN OCRD T2 ON T2."CardCode" = T0."CardCode"
LEFT JOIN OCRG T1 ON T1."GroupCode" = T2."GroupCode"
WHERE T0."DocDate" BETWEEN ADD_MONTHS(CURRENT_DATE, -12) AND CURRENT_DATE
AND T0."CANCELED" = 'N'
GROUP BY T0."CardCode", T0."CardName", T1."GroupName"
ORDER BY SUM(T0."DocTotal") DESC
LIMIT 20In many cases, this query will reveal that 80% of your purchasing spend is concentrated in 20% of your suppliers. With that information, you can negotiate better terms with strategic suppliers and evaluate whether you need to diversify to reduce the risk of excessive dependence.
Query 2: Delivery performance by supplier
That said, purchase amount is only part of the analysis. A cheap supplier that delivers late causes stockouts and unplanned production stoppages. So you need to measure delivery performance: the difference between the date promised on the purchase order and the actual receipt date at the warehouse.

SQL Server
-- Cumplimiento de entrega por proveedor (SQL Server)
-- Compara ShipDate de la OC vs DocDate de la Recepción real
SELECT
T0.CardCode AS [Código Proveedor],
T0.CardName AS [Nombre Proveedor],
COUNT(T2.DocEntry) AS [Nro Recepciones],
AVG(DATEDIFF(DAY, T1.ShipDate, T2.DocDate)) AS [Días Prom Diferencia],
SUM(CASE WHEN T2.DocDate > T1.ShipDate THEN 1 ELSE 0 END) AS [Entregas Tardías],
CAST(
100.0 * SUM(CASE WHEN T2.DocDate <= T1.ShipDate THEN 1 ELSE 0 END)
/ NULLIF(COUNT(T2.DocEntry), 0)
AS DECIMAL(5,2)) AS [Porcentaje Cumplimiento]
FROM OPOR T0
INNER JOIN POR1 T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN PDN1 T3 ON T3.BaseEntry = T1.DocEntry
AND T3.BaseLine = T1.LineNum
AND T3.BaseType = 22
INNER JOIN OPDN T2 ON T2.DocEntry = T3.DocEntry
WHERE T0.DocDate >= DATEADD(MONTH, -12, GETDATE())
AND T0.CANCELED = 'N'
AND T1.ShipDate IS NOT NULL
GROUP BY T0.CardCode, T0.CardName
HAVING COUNT(T2.DocEntry) >= 3
ORDER BY [Porcentaje Cumplimiento] ASCSAP HANA
-- Cumplimiento de entrega por proveedor (SAP HANA)
SELECT
T0."CardCode" AS "Código Proveedor",
T0."CardName" AS "Nombre Proveedor",
COUNT(T2."DocEntry") AS "Nro Recepciones",
AVG(DAYS_BETWEEN(T1."ShipDate", T2."DocDate")) AS "Días Prom Diferencia",
SUM(CASE WHEN T2."DocDate" > T1."ShipDate" THEN 1 ELSE 0 END) AS "Entregas Tardías",
CAST(
100.0 * SUM(CASE WHEN T2."DocDate" <= T1."ShipDate" THEN 1 ELSE 0 END)
/ NULLIF(COUNT(T2."DocEntry"), 0)
AS DECIMAL(5,2)) AS "Porcentaje Cumplimiento"
FROM OPOR T0
INNER JOIN POR1 T1 ON T1."DocEntry" = T0."DocEntry"
INNER JOIN PDN1 T3 ON T3."BaseEntry" = T1."DocEntry"
AND T3."BaseLine" = T1."LineNum"
AND T3."BaseType" = 22
INNER JOIN OPDN T2 ON T2."DocEntry" = T3."DocEntry"
WHERE T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -12)
AND T0."CANCELED" = 'N'
AND T1."ShipDate" IS NOT NULL
GROUP BY T0."CardCode", T0."CardName"
HAVING COUNT(T2."DocEntry") >= 3
ORDER BY "Porcentaje Cumplimiento" ASC
LIMIT 50An on-time percentage below 85% is a critical red flag. However, for this query to work properly, buyers have to record the committed delivery date in the ShipDate field of each purchase order line. Without that data, the analysis loses its validity.
Query 3: Monthly purchasing trend by supplier
Beyond amount and delivery performance, you need to see the trend over time. That way you can detect whether your dependence on certain suppliers is growing or whether spend is spreading more evenly. This query is especially useful for identifying seasonal suppliers or spotting purchases that should be under an annual contract.
SQL Server
-- Monthly purchasing trend by supplier (SQL Server)
SELECT
T0.CardCode AS [Supplier Code],
T0.CardName AS [Supplier Name],
FORMAT(T0.DocDate, 'yyyy-MM') AS [Period],
YEAR(T0.DocDate) AS [Year],
MONTH(T0.DocDate) AS [Month],
COUNT(T0.DocEntry) AS [Invoice Count],
SUM(T0.DocTotal - T0.VatSum) AS [Net Subtotal],
SUM(T0.DocTotal) AS [Total with Tax]
FROM OPCH T0
WHERE T0.DocDate >= DATEADD(MONTH, -12, GETDATE())
AND T0.CANCELED = 'N'
GROUP BY T0.CardCode, T0.CardName,
FORMAT(T0.DocDate, 'yyyy-MM'), YEAR(T0.DocDate), MONTH(T0.DocDate)
ORDER BY T0.CardCode, YEAR(T0.DocDate), MONTH(T0.DocDate)SAP HANA
-- Monthly purchasing trend by supplier (SAP HANA)
SELECT
T0."CardCode" AS "Supplier Code",
T0."CardName" AS "Supplier Name",
TO_VARCHAR(T0."DocDate", 'YYYY-MM') AS "Period",
YEAR(T0."DocDate") AS "Year",
MONTH(T0."DocDate") AS "Month",
COUNT(T0."DocEntry") AS "Invoice Count",
SUM(T0."DocTotal" - T0."VatSum") AS "Net Subtotal",
SUM(T0."DocTotal") AS "Total with Tax"
FROM OPCH T0
WHERE T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -12)
AND T0."CANCELED" = 'N'
GROUP BY T0."CardCode", T0."CardName",
TO_VARCHAR(T0."DocDate", 'YYYY-MM'), YEAR(T0."DocDate"), MONTH(T0."DocDate")
ORDER BY T0."CardCode", YEAR(T0."DocDate"), MONTH(T0."DocDate")After running this query, export the results to Excel and build a line chart by supplier. As a result, you'll have a visual map of your purchasing evolution that you can present at the monthly management meeting.
Query 4: Cross-analysis of purchases by supplier and item category
That said, analyzing suppliers without cross-referencing item categories is seeing only half the problem. This query shows what your company is buying from each supplier, grouped by item group. It's key, for example, to spot duplication: two suppliers selling exactly the same thing without purchasing knowing it, which fragments volume and weakens your negotiating power.
SQL Server
-- Purchases by supplier and item category (SQL Server)
-- Tables: OPCH, PCH1, OITM, OITB
SELECT
T0.CardCode AS [Supplier Code],
T0.CardName AS [Supplier Name],
T3.ItmsGrpNam AS [Item Category],
COUNT(DISTINCT T1.ItemCode) AS [Distinct Items],
SUM(T1.Quantity) AS [Total Quantity],
SUM(T1.LineTotal) AS [Total Amount],
AVG(T1.Price) AS [Average Unit Price]
FROM OPCH T0
INNER JOIN PCH1 T1 ON T1.DocEntry = T0.DocEntry
INNER JOIN OITM T2 ON T2.ItemCode = T1.ItemCode
INNER JOIN OITB T3 ON T3.ItmsGrpCod = T2.ItmsGrpCod
WHERE T0.DocDate >= DATEADD(MONTH, -12, GETDATE())
AND T0.CANCELED = 'N'
AND T1.ItemCode IS NOT NULL
GROUP BY T0.CardCode, T0.CardName, T3.ItmsGrpNam
ORDER BY T0.CardCode, SUM(T1.LineTotal) DESCSAP HANA
-- Purchases by supplier and item category (SAP HANA)
SELECT
T0."CardCode" AS "Supplier Code",
T0."CardName" AS "Supplier Name",
T3."ItmsGrpNam" AS "Item Category",
COUNT(DISTINCT T1."ItemCode") AS "Distinct Items",
SUM(T1."Quantity") AS "Total Quantity",
SUM(T1."LineTotal") AS "Total Amount",
AVG(T1."Price") AS "Average Unit Price"
FROM OPCH T0
INNER JOIN PCH1 T1 ON T1."DocEntry" = T0."DocEntry"
INNER JOIN OITM T2 ON T2."ItemCode" = T1."ItemCode"
INNER JOIN OITB T3 ON T3."ItmsGrpCod" = T2."ItmsGrpCod"
WHERE T0."DocDate" >= ADD_MONTHS(CURRENT_DATE, -12)
AND T0."CANCELED" = 'N'
AND T1."ItemCode" IS NOT NULL
GROUP BY T0."CardCode", T0."CardName", T3."ItmsGrpNam"
ORDER BY T0."CardCode", SUM(T1."LineTotal") DESC
LIMIT 200This query usually produces surprises. It's not unusual to discover that 40% of categories are bought from more than three different suppliers, which points to a concrete opportunity for consolidation and volume savings.

Additional variations and use cases
You can easily adapt these queries to your specific context. For example, if you want to filter only suppliers in a given group, add AND T2.GroupCode = 'TU_GRUPO' to the WHERE clause. In the same way, if you need to compare two half-years, you can create two instances of the same query with different date ranges and join them with UNION ALL.
Also, if your company operates in multiple currencies, add the fields DocCur (document currency) and DocTotalFC (total in foreign currency) to analyze local-currency and foreign-currency purchases separately. That way you'll avoid distortions in the totals when the exchange rate moves significantly between periods.
Finally, to parameterize the dates in the SAP Business One Query Manager, replace the fixed dates with parameters: WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]'. As a result, the user can enter the date range each time the query runs, with no need to edit the SQL code.
Best practices and common mistakes
Here are the most important lessons learned from implementing these queries in real production environments:
Mistake 1: Including cancelled documents. SAP Business One doesn't delete cancelled records from the database; it only flags them with CANCELED = 'Y'. So if you don't filter on this field, your totals will be inflated and the results wrong. Always include AND T0.CANCELED = 'N' in your purchasing queries.
Mistake 2: Confusing OPCH with OPDN. OPCH holds Supplier Invoices (A/P Invoice), while OPDN holds Goods Receipts (Goods Receipt PO). For analyzing actual committed spend, use OPCH. For analyzing the physical flow of goods, use OPDN. They are not interchangeable.
Mistake 3: Not recording the committed delivery date. Query 2 on delivery performance depends on the ShipDate field in the purchase order lines. In many teams, though, that field is left empty. The problem isn't technical: it's cultural. The fix is training the purchasing team to systematically record the date agreed with the supplier before releasing the order.
Best practice 1: Turn these queries into Crystal Reports. Crystal Reports lets you turn these queries into reports with visual charts. As a result, management can consume the information without running SQL manually, which widens the reach and impact of the analysis.
Best practice 2: Use the data as the basis of your purchasing meetings. Instead of reviewing records one by one in SAP, present this consolidated data at your monthly supplier meeting. Just remember that data only creates value when it produces concrete decisions: renegotiations, supplier changes or volume agreements.
Best practice 3: Connect the analysis with your inventory strategy. Suppliers with poor delivery performance should carry a higher safety stock in your inventory planning. That way, supplier analysis becomes a direct input to your stock policy, closing the loop between purchasing, operations and finance.
Official SAP resources
To go deeper into the purchasing module and the SAP Business One database structure, these are the most valuable resources:
- SAP Business One Help Center — complete official documentation of the system
- SAP Community – Business One — forum for questions, tutorials and experiences from the global SAP community
- SAP B1 SDK Documentation — complete reference of system tables, fields and objects
Conclusion: turn your purchasing data into business intelligence
With these four queries you have the foundation to build a supplier analysis system that needs no external tools: everything is already inside your SAP Business One. The next step is to bring this information into your purchasing meetings, use it as the basis for annual negotiations and connect it to your inventory and production decisions.
Digital transformation doesn't start with big projects or new platforms: it starts by making the data you already have work actively for you. Your strategic suppliers, the ones who miss deliveries, the ones who duplicate categories: they're all in your database. You just need the right queries to see them clearly and act on what you find.
If you are a member of Strategic Circle, get the full article with the additional queries, industry-specific use cases and the variations most requested by purchasing managers already running them in production. Go to hectorpincheira.com and activate your membership today.




