Hi,
Try this:
IF (@object_type='202' and (@transaction_type='A' or @transaction_type='U'))
Begin
if exists(SELECT T0.[DocNum] FROM OWOR T0 INNER JOIN WOR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OITW T3 ON T2.ItemCode = T3.ItemCode WHERE T1.[PlannedQty] > T3.[OnHand] and T1.[wareHouse] = T3.[WhsCode] and T0.[Status] = 'p'
and T0.[DocNum] =@list_of_cols_val_tab_del )
begin
set @error='1001'
SET @error_message='No sufficiant Stock As Planned '
end
End
Thanks & Regards,
Nagarajan