cancel
Showing results for 
Search instead for 
Did you mean: 

Autocode Generate

Former Member
0 Kudos

hi,

i am using following query for auto code generation group wise

declare @temp as char(20) 
IF $[OITM.ItmsGrpCod] = 101 
BEGIN 
set @temp=(select isnull(max(right(ItemCode,6)),0) + 1 from OITM where (ItmsGrpCod= 101) and (len(ItemCode)=7)) 
set @temp='FAB'+isnull(replicate(0,6-len(@temp)),'')+@temp 
select cast(@temp as char(20)) 
END
ELSE IF $[OITM.ItmsGrpCod] = 104 
BEGIN 
set @temp=(select isnull(max(right(ItemCode,6)),0) + 1 from OITM where (ItmsGrpCod= 104) and (len(ItemCode)=7)) 
set @temp='BRD'+isnull(replicate(0,6-len(@temp)),'')+@temp 
select cast(@temp as char(20)) 
END

but this does not increment code automatically every time it shows me FAB000001 and BRD000001

thanks

rahul

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

solved