on 10-29-2007 6:47 PM
Hey All,
I was wondering if anyone has some working code or ideas to auto generate an item master code record. I have to do this for a client and I am not really sure how this might work.
Curtis,
I create a sql table as follows:
CREATE TABLE [dbo].[AC_TBLIDX](
[TblName] [varchar](10) COLLATE SQL_Latin1_General_CP850_CI_AS NOT NULL,
[Idx] [int] NOT NULL
) ON [PRIMARY]
Then I use a stored procedure to populate the value the first time, increment each successive time and return the updated.
I call this stored procedure thru code so that I can handle any user errors.
In my opinion this works better than a max function on a field within the oitm table.
You can also add extra fields that store a prefix or suffix.
snippet from stored procedure
if exists(select Idx from [dbo].[AC_TBLIDX] where TblName = @Tbl)
begin
update [dbo].[AC_TBLIDX]
set Idx = Idx + 1
where TblName = @Tbl
end
else
begin
insert into [dbo].[AC_TBLIDX] (TblName, Idx)
values (@Tbl, 0)
end
set @return_value = (select Idx from [dbo].[AC_TBLIDX] where TblName = @Tbl)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Curtis,
There is a SAP document out there that details how to assign an RMA number.
I use the same concept to assign a BP Code, with one exception.
I added a button to the item form that the user can click to assign the new item number. I do not use a formatted search.
Hope this helps.
John
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi curtis
If your using alphanumeric or numeric you could add a formatted search to the Itemcode field.. It depends on how u want the code generated the rest shud be logic i guess..
Regards
Aris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Curtis,
Are you trying to use only numerical numbers or is it a Alpha numeric combination?
Any sample numbers you have in mind?
Suda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
7 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.