cancel
Showing results for 
Search instead for 
Did you mean: 

SP to Block GRPO Qty if greater than PO Qty

Former Member
0 Kudos

Hi all,

I need to block the GRPO Document when adding it if the Qty in the GRPO is greater than the PO Qty.

But this Stored Procedure blocks me even when i raise the GRPO with Qty less than the PO Qty.

IF @transaction_type IN ('A') AND

(@Object_type = '20')

BEGIN

IF EXISTS (SELECT T1.BaseEntry

FROM dbo.OPDN T0

INNER JOIN dbo.PDN1 T1 ON T1.DOCENTRY = T0.DocEntry

INNER JOIN dbo.POR1 T2 ON T2.DOCENTRY = T1.BaseEntry

WHERE T1.BaseType = '22' AND

T1.ItemCode = T2.ItemCode AND

T1.BaseLine = T2.LineNum AND

T0.DOCENTRY = @list_of_cols_val_tab_del

GROUP BY T1.BaseEntry

HAVING SUM(T1.Quantity) > SUM(T2.OpenQty))

Begin

SELECT @Error = 10, @error_message = 'GRPO quantity is greater than PO  quantity'

End

END

Is something wrong with this SP...

Accepted Solutions (1)

Accepted Solutions (1)

former_member188586
Active Contributor

Hi

Check bellow Sp

--------------- Validation for Goods Receipt PO Restricting Excess Qunatity ----------------------------

IF @Object_type = '20' and @transaction_type = 'A'

BEGIN

declare  @line int

SELECT @line = (LineNum + 1)

From PDN1

Where PDN1.DocEntry = @list_of_cols_val_tab_del

   and (Quantity > BaseOpnQty)

Order by LineNum

If (not ISNULL(@line, 0) = 0)

begin

  Set @error = 10

  Set @error_message = 'Line quantity' + CONVERT(nvarchar(4), @line) +' is more then open quantity !'

end

END

Thanks& Regards

AndakondaRamudu

Former Member
0 Kudos

Hi AndakondaRamudu,

This works ...

What is actually wrong with the above SP...?

nikunjmehta2290
Participant
0 Kudos

Hi,

Please help me this query conversion in HANA SAP Business One.

Regards,

Nikunj

Answers (0)