cancel
Showing results for 
Search instead for 
Did you mean: 

Auto item code generation

01-15-2011 10:49 AM
358 views 5 comments
0 Likes
SAP Managed Tags
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

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Likes

Hi Naveen.......

Try this and just replace the '?' by your alphabets before code number as per your requirement.....

declare @temp as char(15)
IF ($[OITM.ItemType]) = 'I'  And ($[OITM.ItmsGrpCod]) =100
	BEGIN
		set @temp=(select max(right(itemcode,6)) + 1 from oitm where 

(itemtype='I') and (len(itemcode)=11) and (left(itemcode,5)='?'))
		set @temp='?'+isnull(replicate(0,6-len(@temp)),'')+@temp
		select isnull(cast(@temp as char(15)),'?000001')
		
	END

Hope this will help you.......

Regards,

Rahul

jitin_chawla
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

Please check Note No. : 1378434 regarding the issue mentioned by you. The same explains the steps how to handle the issue.

Kind Regards,

Jitin

SAP Business One Forum Team

Former Member
0 Likes

Hi,

In order to get auto item code generation, first thing you need is to decide naming convention. If their database is not new, that will depend on their current itemcode pattern.

Thanks,

Gordon

Former Member
0 Likes

Hi Naveen,

Please find the below link it will help you.

[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0daad0a-70ac-2d10-6d80-dd255dec7e74?quicklink=index&overridelayout=true]

Regards,

Rakesh N

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