cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

Hi Friends,

My problem is this. My client is want automatic item code generation so how I can do this can you please suggest me.

0 Likes
View Entire Topic
Former Member
0 Likes

Hi Naveen,

I found these two fms's which would enable automatic item code generation. See if it helps you.


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

And:

DECLARE
@NUM AS CHAR(7)
SET @NUM = 
(SELECT RIGHT(MAX(CardCode), 7) FROM OITM)

SET @NUM = @NUM + 1

BEGIN
IF @NUM IS NULL OR @NUM = 0
BEGIN
SELECT 'I0000001'
END

IF @NUM < 10
BEGIN
SELECT 'I000000' + @NUM
END
IF @NUM > 9 AND @NUM < 100
BEGIN
SELECT 'I00000' + @NUM
END

----COMPLETE THE CODE
END

Thanks,

Joseph