Hi Chetan,
Try this simple code.
IF @transaction_type in ('U','A') AND @object_type = '18'
Begin
IF exists(SELECT T0.[DocEntry]
FROM OPCH T0
WHERE T0.DocEntry = @list_of_cols_val_tab_del
AND T0.NumAtCard in (select OPCH.NumAtCard from OPCH where OPCH.DocEntry = T0.DocEntry and OPCH.CardCode = T0.CardCode))
BEGIN
SET @error = 18
SET @error_message = 'Duplicate Vendor Ref Number!'
END
END
Regards,
Alvin