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.
Request clarification before answering.
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')
ENDHope this will help you.......
Regards,
Rahul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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))
ENDAnd:
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
ENDThanks,
Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 12 | |
| 12 | |
| 9 | |
| 7 | |
| 7 | |
| 6 | |
| 3 | |
| 3 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.