Friday 3 February 2017

Stored Procedure for Part No Duplicate in Item Master




IF @transaction_type in ('U', 'A' ) AND @object_type = '4' 

BEGIN

If 1 < (SELECT count(T1.FrgnName) FROM OITM T1 
where T1.FrgnName in (SELECT T0.FrgnName FROM OITM T0 WHERE T0.ItemCode =@list_of_cols_val_tab_del and (t0.frgnName not in ( '*for inventory*' )))) 
Begin
SET @error = 4013
SET @error_message = N'Part Number cannot be duplicated, Please check again !!!'

End
END

Creation of View for G/L Account Selected in BP Master Data


CREATE View [dbo].[OCRDFN2]
as
(
Select
CardName,
CardCode,
CardFName ,
 CASE    
      when DebPayAcct = '_SYS00000000227' then '12700001-001'
      when DebPayAcct = '_SYS00000000617' then '21180001-001'
      when DebPayAcct = '_SYS00000000230' then '12700001-006'
      when DebPayAcct = '_SYS00000000620' then '21180001-006'  
      when DebPayAcct = '_SYS00000000618' then '21180001-004'
      when DebPayAcct = '_SYS00000000228' then '12700001-004'
      when DebPayAcct = '_SYS00000000229' then '12700001-005'
      when DebPayAcct = '_SYS00000000619' then '21180001-005'
 End 'DebPaySeg',
 CASE 
      when DebPayAcct = '_SYS00000000227' then 'Bangalore'
      when DebPayAcct = '_SYS00000000617' then 'Bangalore'
      when DebPayAcct = '_SYS00000000230' then 'Mumbai'
      when DebPayAcct = '_SYS00000000620' then 'Mumbai'  
      when DebPayAcct = '_SYS00000000618' then 'Chennai'
      when DebPayAcct = '_SYS00000000228' then 'Chennai'
      when DebPayAcct = '_SYS00000000229' then 'Pune'
      when DebPayAcct = '_SYS00000000619' then 'Pune'
 End 'DebPay',
 CASE
      when Dpmclear =   '_SYS00000000149' then '47000003-001'
      when Dpmclear =   '_SYS00000000621' then '21180002-001'
      when Dpmclear =   '_SYS00000000232' then '12700003-001'
      when Dpmclear =   '_SYS00000000624' then '21180002-006'
      when Dpmclear =   '_SYS00000000235' then '12700003-006'
      when Dpmclear =   '_SYS00000000233' then '12700003-004'
      when Dpmclear =   '_SYS00000000622' then '21180002-004'
      when Dpmclear =   '_SYS00000000623' then '21180002-005'
      when Dpmclear =   '_SYS00000000234' then '12700003-005'
   End   'DebClearSeg',
CASE
      when Dpmclear =   '_SYS00000000149' then 'Bangalore'
      when Dpmclear =   '_SYS00000000621' then 'Bangalore'
      when Dpmclear =   '_SYS00000000232' then 'Bangalore'
      when Dpmclear =   '_SYS00000000624' then 'Mumbai'
      when Dpmclear =   '_SYS00000000235' then 'Mumbai'
      when Dpmclear =   '_SYS00000000233' then 'Chennai'
      when Dpmclear =   '_SYS00000000622' then 'Chennai'
      when Dpmclear =   '_SYS00000000623' then 'Pune'
      when Dpmclear =   '_SYS00000000234' then 'Pune'
   End 'DebClear',
  DebPayAcct , DpmClear from OCRD )
GO