Hi Experts ,
I tried to right store procedure to restrict the Delivery should not exceed to reserve invoice but its not taking . this is my store procedure
IF @transaction_type IN (N'A', N'U') AND
(@Object_type = N'15')
begin
if exists (SELECT T0.BaseEntry, SUM(T0.Quantity)
FROM dbo.DLN1 T0 INNER
JOIN dbo.INV1 T1 ON T1.DOCENTRY =
T0.BASEENTRY
WHERE T0.BaseType = 17 AND T0.ItemCode =
T1.ItemCode AND T0.BaseLine = T1.LineNum
and T0.DOCENTRY = @list_of_cols_val_tab_del
GROUP BY T0.BaseEntry
HAVING (SUM(T0.Quantity) > SUM(T1.Quantity)) or sum(t0.quantity) >
sum(t0.BaseOpnQty))
begin
select @Error = 10, @error_message = 'Delivery quantity is greater than Reserve qty.'
end
end
Please help me to create this store Procedure .
Thanks