In SAP Business One, users can post a delivery with more quantity than the sales order allows. To block delivery quantity that exceeds the sales order, add a validation to the SBO_SP_TransactionNotification stored procedure. When a user tries to post an over-delivery, SAP Business One stops the transaction and shows an error message with the line number that needs correcting.
Why block delivery quantity above the sales order?
Over-deliveries cause stock differences, billing disputes and extra returns or credit notes. Customers receive goods they did not order, and your warehouse and finance teams spend time reversing documents. A check at posting time stops the problem at the source.
How to add the query
- Log in to Microsoft SQL Server Management Studio.
- Expand Databases.
- Expand your company database (in this example, SVTL2022).
- Expand Programmability.
- Expand Stored Procedures.
- Scroll down to dbo.SBO_SP_TransactionNotification, right-click it and select Modify.
- Paste the query in the section marked “Insert your query here”.
- Click Execute to save the procedure.
Tip: Test every change to SBO_SP_TransactionNotification in a test company database first, and keep a copy of the original procedure before you modify it.
Query to block delivery quantity greater than the sales order
IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'15')
BEGIN
DECLARE @numlinii int
SELECT @numlinii = (LineNum + 1)
FROM DLN1
WHERE DLN1.DocEntry = @list_of_cols_val_tab_del
AND ((Quantity > BaseOpnQty))
ORDER BY LineNum ASC
IF (NOT ISNULL(@numlinii, 0) = 0)
BEGIN
SET @error = 10
SET @error_message = N'Delivered quantity cannot exceed Sales order quantity ' + CONVERT(nvarchar(4), @numlinii) + N' !'
END
END
How the query works
- It runs when a delivery (object type 15) is added or updated.
- It compares the quantity on each delivery line (DLN1) with the open quantity left on the base sales order line (BaseOpnQty).
- If any line is higher, SAP Business One blocks the posting and shows the line number in the error message.
Related SAP Business One queries
You can apply the same approach to other documents. See how to block invoice quantity above the sales order and how to block GRPO quantity above the purchase order.