Skip to Content
0
Former Member
May 08, 2014 at 04:56 AM

Validation Query

364 Views

Hi Experts,

To restrict inventory transfer to be posted from one whs to other warehouses. i have written below SP. Please check below query.

But whenever i update my bill of material, it is stopping me to update and add the bill of material. I am not getting how it is relating to Bill of Material. It is showing the error "[Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting the nvarchar value 'SB 512HN4 P- L3' to datatype int.(CINF)".

If i remove my below query from SP. Then it is working fine. Please help me to solve this.

IF @transaction_type=N'A' AND @Object_type = N'67'

Declare @a nvarchar(10)

Declare @b nvarchar(10)

set @a = (Select a.Filler from OWTR a inner join WTR1 b on a.DocEntry = b.DocEntry

where a.UserSign = 76 and a.DocEntry =@list_of_cols_val_tab_del)

set @b = (select a.ToWhsCode from OWTR a inner join WTR1 b on a.DocEntry = b.DocEntry

where a.UserSign = 76 and a.ToWhsCode = b.WhsCode and a.DocEntry

=@list_of_cols_val_tab_del)

BEGIN

if (@a <> '12') --and (@b <> 05)

begin

SET @error = '201'

SET @error_message = N'You are not permitted to select other warehouse except 12....!'

end

if (@b <> 05)

begin

SET @error = '202'

SET @error_message = N'You are not permitted to select other warehouse except 05....!'

end

if exists (select a.DocEntry from OWTR a inner join WTR1 b on a.DocEntry = b.DocEntry

where a.ToWhsCode <> b.WhsCode and a.DocEntry = @list_of_cols_val_tab_del

and a.UserSign = 76)

begin

SET @error = '203'

SET @error_message = N'Whs Code(ToWhsCode) at Header and Items level should be same....!'

end

END

Please let me know how can i come out of this error.