cancel
Showing results for 
Search instead for 
Did you mean: 

GRPO Qty must not Exceed the PO Qty

Former Member
0 Kudos

Hi Experts,

I need a Query in such a manner that it should not allow me to add the GRPO if GRPO Qty exceeds.

Reply.

Mona.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

thanks a lot

former_member186095
Active Contributor
0 Kudos

Hi Mona,

Here is an alternative beside previous answer:

IF @transaction_type IN (N'A', N'U') AND

(@Object_type = N'20')

begin

if exists (SELECT T0.BaseEntry, SUM(T0.Quantity)

FROM [dbo].[PDN1] T0 INNER

JOIN [dbo].[POR1] T1 ON T1.DOCENTRY =

T0.BASEENTRY

WHERE T0.BaseType = 22 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 =

'GRPO quantity is over PO quantity'

end

end

Rgds,

Former Member
0 Kudos

Thanks a lot it works

Edited by: Mona on Nov 13, 2008 8:01 AM

former_member204969
Active Contributor
0 Kudos

Try this code in the Transaction notification stored procedure:

IF @transaction_type IN (N'A', N'U') AND (@Object_type = N'20')
BEGIN
declare  @numlinii int
SELECT @numlinii = (LineNum + 1) FROM PDN1
WHERE PDN1.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'Line ' + CONVERT(nvarchar(4), @numlinii) + N' is invalid !'
end
END

(It is from an old forum thread.)