Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

GRPO Validation

Hi all,

I am trying to provide validation to Grpo document.

my requierment is as follows.

1) i have one PO with 10 qty.

2) i create one grpo doc. based on this PO and i receive 4 qty now my open qty is 6.

3) when next time i create grpo based on this po ,grpo doc will bydefault display 6 qty .

now my requierment is like if increase grpo qty greater than partialy open po Qty(in this example >6) it should give error.

i have following validation but its not working with partial delivery of purchase order.

  

--GRPO Quantity Should not Be Greater than PO Quantity.
IF @transaction_type IN (N'A', N'U') AND 
(@Object_type = N'20')
begin 
if exists (SELECT T0.BaseEntry,sum(T0.Quantity),sum(T1.Openqty) 
FROM dbo.PDN1 T0 INNER 
JOIN dbo.POR1 T1 ON T1.DocEntry = 
T0.BaseEntry inner JOIN dbo.OPDN T2 ON T0.DocEntry = T2.DocEntry 
WHERE T0.BaseType = 22 AND T0.BaseLine 
= T1.LineNum --and T0.ItemCode = T1.ItemCode
and T0.DOCENTRY = @list_of_cols_val_tab_del and T2.DocType='I' 
group by T0.BaseEntry
Having (Sum (T0.Quantity) > sum (T1.Quantity )) or (Sum (T0.quantity) > sum(T1.openqty)))
begin
select @Error = 10, @error_message = 
'Item Qty In GRPO can not be greater than Item Qty in Purchase Order Document'
end
end

kindly provide the solution.

thanx in advance.

Former Member
Former Member replied

Hi,

Try this

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 greater PO quantity'
end
end

Hope this helps,

Son

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question