Skip to Content
0
Former Member
Apr 20, 2012 at 12:36 PM

Query on openqty doesn't work in SP_TransactionNotification

71 Views

Hi everybody,

we would like to avoid that a user can add more pieces in OPDN as originally was ordered in OPOR. So i want to modify the SP_TransactionNotification in that way:

If @object_type = '20' and @transaction_type = 'A'

Begin

declare @baseqty int

declare @inqty int

declare @minline1 int

declare @maxline1 int

declare @baseline int

declare @baseentry int

set @minline1 = (select min(T0.linenum) from PDN1 T0 where T0.docentry=@list_of_cols_val_tab_del)

set @maxline1 = (select max(T0.linenum) from PDN1 T0 where T0.docentry=@list_of_cols_val_tab_del)

Begin

WHILE @minline1<=@maxline1

BEGIN

set @baseline = (select T0.BaseLine From PDN1 T0 where T0.DocEntry=@list_of_cols_val_tab_del AND T0.linenum=@minline1)

set @baseentry = (select T0.BaseEntry From PDN1 T0 where T0.DocEntry=@list_of_cols_val_tab_del AND T0.linenum=@minline1)

set @baseqty = (select T1.OpenCreQtyFROM POR1 T1 WHERE T1.DocEntry = @baseentry AND T1.LineNum = @baseline)

SET @inqty = (SELECT T0.Quantity FROM PDN1 T0 WHERE T0.docentry=@list_of_cols_val_tab_del AND T0.linenum=@minline1)

if @inqty > @baseqty

BEGIN

SET @error = 1

SET @error_message = @baseqty

End

SET @minline1=@minline1+1

end

End

End

it works quite nice if i use T1.Quantity in the line with set @baseqty but if i set it to T1.OpenCreQty or T1.OpenQty the error_message always return 0 as value (but if i query it in SAP it's the correct value, not 0 because there are still pieces open 😉)

I can't imagine why, but maybe some of you knows the answer 😊

kr

Manuel