How to Create Auto Number?Without using No Series CodeUnit

hai there…

how to create autonumber ?

for example like this

Manufacture = A → lookup from table

Item Category Code = 01 → lookup from table

Product Group = 01 → lookup from table

then The No. would be A-01-01-0001

if there is another criteria like this then it should be A-01-01-0002

the bold one is the increasing number

nevertheless, if there is another criteria, it would back to 1

like this

Manufacture = B → lookup from table

Item Category Code = 01 → lookup from table

Product Group = 01 → lookup from table

then The No. would be B-01-01-0001

How is it be possible? could any of you help me to solve this problem?

thanx anyway :slight_smile:

How come you do not want to use the no series with type code?

there’s too many trees on

manufacture

Inventory Posting Group

Inventory Code

product Group

so I want auto generate for autoincreasing

You could create a new table, and add a field for each criteria, and also a field for the last used value with this combo of criterias…

Put all criteria-fields in the primary key…

Then…
IF NewRec.GET(Crit1,Crit2,Crit3) THEN BEGIN
NewRec.LastUsedField := INCSTR(NewRec.LastUsedField);
NewRec.MODIFY;
END ELSE BEGIN
… insert the record with the needed value in LastUsedField
END;
CodeToUse := Crit1 + ‘-’ + Crit2 + ‘-’ + Crit3 + ‘-’ + NewRec.LastUsedField;

my code is

GET(“Entry No.”);
“NKS No.” := “Manufacture Code” + ‘-’ + “Inventory Posting Group” + “Item Category Code” + ‘-’

  • “Product Group” + ‘-’ + INCSTR(LastEntryNo);
    MODIFY;

→ It didn’t work…

because last entry no is integer…

I was under the impression (from your own post earlier) that you wanted the final no. to have a given format (0001), and therefore concluded that you used datatype Code…

Integer is increased simply by adding 1.

What I would do is create standard NAV numbering series for all combinations, and develop logic to select the right one, and from there let the standard numbering series take care of the numbers.

it’s so simple

just add code
“NKS No.” := INCSTR(“NKS No.”);

thans for your response :slight_smile: