Skip to Content
0
Former Member
Jan 04, 2011 at 10:05 AM

Stored procedure in purchase order for duplicate item for a vendor

315 Views

Hi all

I have written a stored procedure for duplicate item for vendor the output i need from this SP is whenever for a vendor we will raise purchase order the system should check that their shouldn't be any po in the system for the same item by the selected vendor. Its working fine when only one item is selected but it is behaving wrongly when more than one item is selected.

If (@object_type='22' and @transaction_type='A')

BEGIN

Declare @Vend as varchar(200)

Declare @ItemCode as varchar(200)

Select @Vend =CardCode From OPOR Where DocEntry = @list_of_cols_val_tab_del

Select @ItemCode=ItemCode From POR1 Where DocEntry=@list_of_cols_val_tab_del

IF 1 !=(Select Count(T0.DocEntry) From OPOR T0 Inner Join POR1 T1 On T0.DocEntry=T1.DocEntry Where T0.CardCode=@Vend and T1.ItemCode=@ItemCode)

Begin

select @error =1

select @error_message = 'Item Code Already Exists For This Vendor'

end

end

Thanks

Rashid.