Skip to Content
0
Dec 30, 2022 at 06:56 AM

SP not getting customer details right

99 Views

Hey everyone,

This is my SP:

if @object_type in ('112') and @transaction_type in ('A','U')

begin

if exists(

Select T1.CardCode

from ODRF T0

left outer join OCRD T1 on T0.CardCode=T1.CardCode

where (( t1.Balance + T1.DNotesBal + t1.OrdersBal )>t1.CreditLine)

and T1.GroupCode != 107

and T0.ObjType='17'

and T0.DocEntry= @list_of_cols_val_tab_del

)

begin

set @error = -230

set @error_message = 'Cannot add document.| Credit Limit Exceeded.'

end

end

What I want is if customer balance exceeds the credit limit show erorr message instead of sending approval but somehow its not working according to my need. Maybe its not fetching the customer data right. Can someone tell me what I am doing wrong. Thanks!