SAP Business One sales commissions: the phrase sounds like an administrative procedure, but in most companies, it is a silent source of internal conflict. Every month-end, someone in finance opens an Excel spreadsheet, manually cross-references invoices with salesperson names, applies a percentage whose origin nobody quite remembers, and hopes no one complains. When a salesperson asks why their commission dropped compared to the previous month, the answer is usually an awkward silence followed by a «let me check on that.» The real problem is not a lack of effort: it is the absence of a traceable, repeatable, and verifiable calculation directly from the SAP Business One database.
Why this costs you more than an unbalanced spreadsheet
A salesperson who doesn't trust their commission statement stops pushing the sales that suit you best and starts pushing the ones that suit them best. Furthermore, every dispute consumes hours from finance, sales management, and the salesperson themselves—hours that don't appear in any productivity report but are felt in the atmosphere. Therefore, commission calculation is not a minor accounting exercise: it is a piece of corporate governance that connects commercial strategy with the actual behavior of the sales team.
When the commission is calculated with a SQL query directly on the SAP Business One database, three things change immediately. First, the number stops depending on who put the spreadsheet together that month. Second, any salesperson can request the breakdown and you can show it without improvising. Third, and perhaps most importantly, general management gets real visibility into commercial costs without waiting for the accounting close.
Prerequisites before writing the first query
Before sitting down to write SQL, you need to solve three things outside the database. Consequently, skipping this step guarantees that the query will be technically correct but commercially wrong.
- Read-only access to the SAP Business One license database, either via SQL Server Management Studio or SAP HANA Studio.
- Configured commission percentage Go to Sales → Setup → Sales Persons / Buyers for each active sales employee (this populates the Commission field in the OSLP table).
- Explicit commercial criterionis the commission paid on billed amounts or on actually collected amounts? This decision, made by the sales management and not by IT, completely changes the query you are going to build.
Step-by-step tutorial: from configuration to query
Step 1: Verify that each vendor has their percentage uploaded
Go to Administration → Initial Data Definition → Sales → Salespersons/Buyers and check that the commission field is not blank or zero by default. It's surprising how many companies spend months calculating commissions «by hand» because they never completed this master field. Without this correct data, any query you build will return zeros or values inherited from an old configuration.
Step 2: Decide the calculation basis: issued billing vs. actual collections
Calculating based on billings is simpler, but it rewards the salesperson even when the client never pays. Calculating based on actual collections is fairer to the company's cash flow, although it requires a more elaborate query that cross-references invoices with payment receipts. For example, a business with slow-paying clients should lean toward the second model; one with immediate collection or credit card payments can stick with the first without major risk.
Step 3: Build and validate the query before automating it
Use the SAP Business One Query Generator to test the logic on a closed and known period where you already know how much was paid in the previous payroll. This way you can compare the query result against the historical number and detect differences before a salesperson detects them for you.

The 3 queries that solve the problem (SQL Server and HANA)
Below are three queries that you can adapt to your schema. All assume that the SlpCode (sales employee) field is correctly assigned in each document, something that is worth auditing before trusting the results.
Commission on monthly billing
The simplest version: take the sales invoices for the period and apply the percentage configured in the salesperson master.
SQL Server
-- Commission on billing issued in the month
SELECT
S.SlpCode,
S.SlpName AS SalesEmployee,
S.Commission AS CommissionPercentage,
COUNT(DISTINCT T0.DocEntry) AS InvoiceCount,
SUM(T0.DocTotal - T0.VatSum) AS NetSales,
SUM((T0.DocTotal - T0.VatSum) * S.Commission / 100) AS CalculatedCommission
FROM OINV T0
INNER JOIN OSLP S ON T0.SlpCode = S.SlpCode
WHERE T0.DocDate >= '2026-08-01' AND T0.DocDate < '2026-09-01'
AND T0.CANCELED = 'N'
GROUP BY S.SlpCode, S.SlpName, S.Commission
ORDER BY CalculatedCommission DESC
SAP HANA
-- Commission on billing issued in the month
SELECT
S."SlpCode",
S."SlpName" AS "SalesPerson",
S."Commission" AS "CommissionPercentage",
COUNT(DISTINCT T0."DocEntry") AS "InvoiceCount",
SUM(T0."DocTotal" - T0."VatSum") AS "NetSales",
SUM((T0."DocTotal" - T0."VatSum") * S."Commission" / 100) AS "CalculatedCommission"
FROM OINV T0
INNER JOIN OSLP S ON T0."SlpCode" = S."SlpCode"
WHERE T0."DocDate" >= '2026-08-01' AND T0."DocDate" < '2026-09-01'
AND T0."CANCELED" = 'N'
GROUP BY S."SlpCode", S."SlpName", S."Commission"
ORDER BY "CalculatedCommission" DESC
Note that the commission is calculated on the net amount (DocTotal minus VatSum), not on the total including taxes. Paying commission on VAT is a common mistake that artificially inflates the commercial cost without anyone noticing for months.
Query 2: Commission on actual collection (the one that really avoids overpaying)
This version pays only what the customer actually paid, matching the invoice with the payment receipts through the payment application table.
SQL Server
-- Commission on actual monthly collections
SELECT
S.SlpCode,
S.SlpName AS Salesperson,
SUM(R2.SumApplied) AS TotalCollected,
SUM(R2.SumApplied * S.Commission / 100) AS CommissionOnCollection
FROM RCT2 R2
INNER JOIN OINV T0 ON R2.DocEntry = T0.DocEntry AND R2.InvType = 13
INNER JOIN ORCT R1 ON R2.DocNum = R1.DocEntry
INNER JOIN OSLP S ON T0.SlpCode = S.SlpCode
WHERE R1.DocDate >= '2026-08-01' AND R1.DocDate < '2026-09-01'
AND R1.CANCELED = 'N'
GROUP BY S.SlpCode, S.SlpName
ORDER BY CommissionOnCollection DESC
SAP HANA
-- Commission on actual monthly collections
SELECT
S."SlpCode",
S."SlpName" AS "SalesEmployee",
SUM(R2."SumApplied") AS "TotalCollected",
SUM(R2."SumApplied" * S."Commission" / 100) AS "CommissionOnCollection"
FROM RCT2 R2
INNER JOIN OINV T0 ON R2."DocEntry" = T0."DocEntry" AND R2."InvType" = 13
INNER JOIN ORCT R1 ON R2."DocNum" = R1."DocEntry"
INNER JOIN OSLP S ON T0."SlpCode" = S."SlpCode"
WHERE R1."DocDate" >= '2026-08-01' AND R1."DocDate" < '2026-09-01'
AND R1."CANCELED" = 'N'
GROUP BY S."SlpCode", S."SlpName"
ORDER BY "CommissionOnCollection" DESC
However, this model requires clear communication with the sales team: a salesperson who closed a large sale in August but whose client pays in October will not see that commission reflected until the money comes in. Therefore, document this rule in writing before implementing it, not after the first complaint.
Query 3: Vendor ranking with average ticket and sales seniority
Beyond the amount to be paid, this query gives you a snapshot of sales performance: who sells the most, who has the highest average ticket size, and who has gone the longest without closing a deal.
SQL Server
-- Commercial ranking with average ticket
SELECT
S.SlpName AS Salesperson,
COUNT(DISTINCT T0.DocEntry) AS NumInvoices,
SUM(T0.DocTotal) AS TotalSales,
AVG(T0.DocTotal) AS AverageTicket,
DATEDIFF(day, MAX(T0.DocDate), GETDATE()) AS DaysSinceLastSale
FROM OINV T0
INNER JOIN OSLP S ON T0.SlpCode = S.SlpCode
WHERE T0.DocDate >= '2026-01-01' AND T0.CANCELED = 'N'
GROUP BY S.SlpName
ORDER BY TotalSales DESC
SAP HANA
-- Sales ranking with average ticket
SELECT
S."SlpName" AS "Salesperson",
COUNT(DISTINCT T0."DocEntry") AS "NumInvoices",
SUM(T0."DocTotal") AS "TotalSales",
AVG(T0."DocTotal") AS "AverageTicket",
DAYS_BETWEEN(MAX(T0."DocDate"), CURRENT_DATE) AS "DaysSinceLastSale"
FROM OINV T0
INNER JOIN OSLP S ON T0."SlpCode" = S."SlpCode"
WHERE T0."DocDate" >= '2026-01-01' AND T0."CANCELED" = 'N'
GROUP BY S."SlpName"
ORDER BY "TotalSales" DESC
This report is especially useful in the monthly sales committee meeting because it shifts the conversation from «how much we pay each salesperson» to «how each sales territory is evolving,» which is the question that general management truly cares about.


Variations for real businesses
No company keeps a simple commission structure for long. That is why it is worth knowing three variations that almost always end up being necessary.
tiered commission by goals instead of a fixed percentage, create a User-Defined Table (UDT) with the target brackets and their associated percentage, and use a CASE WHEN in the query to apply the corresponding bracket based on the salesperson's accumulated sales in the period. This way, the incentive grows when the result grows, instead of being flat all month.
Commission differentiated by product line: If your company pays differently by business line, move the invoice header calculation (OINV) to the detail level (INV1) and cross-reference each line with the item group (OITB) to apply the correct percentage item by item, not invoice by invoice.
Exclusion of credit notes: as a result of a return, the commission already paid should be deducted in the following period. Add a second query on ORIN/RIN1 with the same criteria and subtract it from the gross calculation before issuing the final payment.
The mistakes that ruin your sales team's trust
Most commission problems are not SQL problems: they are business criteria poorly defined before writing the query. However, some technical errors appear over and over again.
- Pay commission on VAT instead of the net amount, which inflates the commercial cost without anyone noticing until the annual audit.
- Ignore credit notes, paying commission on sales that were later partially or fully reversed.
- Mix invoice date with collection date without the sales team knowing under what criteria they are being paid, generating avoidable complaints.
- Do not audit the SlpCode field in the documents, which can leave sales without an assigned salesperson or assigned to the wrong salesperson due to a typing error.
- Automate payment before validating the query against a known historical period, skipping Step 3 of the tutorial.
Official SAP resources
To delve deeper into the table structure and seller configuration, the official documentation is the most reliable starting point:
- SAP Business One SDK Help – Sales Employee (OSLP) table reference on the SAP Help Portal.
- SAP Business One Query Generator – User guide for the query generator within the application (Tools → Query Generator).
- SAP Community – discussion forums on commissions and sales structure in SAP Business One.
The commission is not just a payment, it is a signal
Every time a salesperson receives their commission statement, they also receive a message about what the company values: gross sales, collections, customer loyalty, or the actual profitability of each transaction. If that message is built on an improvised spreadsheet, it is a weak message. If it is built with a traceable, auditable, and consistent SQL query month after month, it is a sign that management knows exactly what it is paying for and why.
If you want the full detail of these queries, the variations with UDTs for tiered goals, and the step-by-step configuration guide, the Strategic Circle community at hectorpincheira.com has access to the complete tutorial, with all scripts ready to adapt to your schema.




