Skip to Content
Former Member
Apr 05, 2013 at 07:18 PM

Problem with a function in SBO_SP_TransactionNotification


Hi Experts!

I'm trying to do the following blockade: I created a User Field that save a Contract Date and another save the maximum a determined customer can spend since the contract date until now, when a Delivery is been done and the maximum the customer can spend was overtaken, so the delivery can't be added. I did the following function and put into the SBO_SP_TransactionNotification, but it doesn't work, Does anyone have idea of what I'm doing wrong?

IF @sObjTyp = '15'

AND @sTraTyp IN ('A')


DECLARE @customer varchar

set @customer = ''

declare @valueTotalDeliveries numeric(19,6)

set @valueTotalDeliveries = 0

declare @valueContract numeric(19,6)

set @valueContract = 0

Select @customer = T1.CardCode from ODLN T1 Where T1.[DocNum] = convert(varchar,@sKeyVal)

select @valueTotalDeliveries = convert(numeric(19,6),sum(((t1.Price))*t1.Quantity) )

from odln t0 inner join DLN1 t1 on t0.DocEntry = t1.DocEntry inner join OCRD t2 on

t0.CardCode = t2.CardCode inner join OITM t4 on t1.ItemCode = t4.ItemCode

lEFT Join RDN1 T3 on T1.DocEntry = T3.BaseEntry

AND T1.LineNum = T3.BaseLine

AND t1.ObjType = t3.BaseType

where t0.DocDate >= t2.U_Beginning_Contract

and t2.U_Beginning_Contract is not null and convert(varchar,t2.CardCode) like @customer

and (t4.QryGroup1 = 'Y' or t4.QryGroup4 = 'Y')

and t3.BaseEntry is null group by t2.CardCode

select @valueContract = convert(numeric(19,6),U_valueContract) from OCRD where CardCode = @customer

IF @valueContract<@valuetotalDeliveries


SET @error = 1

SET @error_message=' Total value of the Deliveries greater than the allowed by Contract!'