Coder Challenge - Tricky Item creation

Steve
Member Posts: 81
Hello All,
I have a client that requires us to create thousands of item numbers based on a intelligent number scope. I need a way to create all the combinations of item numbers based on these options.
Item Number = Type + Style + Color + Option
Type
1
2
3
Style
A01 -
A02
A03
A04
Color
L01
L02
T01
T02
V01
Option
S
F
0
** There are many more options per category, but I minimized this for the example.
So I would need write code to read each of these and combine them into new item numbers.
i.e.
1A01L01S
1A01L01F
1A01L010
1A01L02S
1A01L02F
1A01L020
And so on.
Any ideas?
I have a client that requires us to create thousands of item numbers based on a intelligent number scope. I need a way to create all the combinations of item numbers based on these options.
Item Number = Type + Style + Color + Option
Type
1
2
3
Style
A01 -
A02
A03
A04
Color
L01
L02
T01
T02
V01
Option
S
F
0
** There are many more options per category, but I minimized this for the example.
So I would need write code to read each of these and combine them into new item numbers.
i.e.
1A01L01S
1A01L01F
1A01L010
1A01L02S
1A01L02F
1A01L020
And so on.
Any ideas?
Steve
0
Comments
-
Hi Steve,
You could use the code below. All you need to do is create a table for each component of the item number (type, style, color, option) and fill these tables with all the available elements (for example in the Style_Table: A01, A02, ..).
After that you create a CodeUnit or Report in which you put the code and run it. Ofcourse you might have to adjust the code depending on the types of fields you put in the new tables.//GeneratedItem [code (array) variable] IF Type_Table.FINDSET THEN REPEAT GeneratedItem[1] := Type_Table.Type; IF Style_Table.FINDSET THEN REPEAT GeneratedItem[2] := FORMAT(Style_Table.Style); IF Color_Table.FINDSET THEN REPEAT GeneratedItem[3] := FORMAT(Color_Table.Color); IF Option_Table.FINDSET THEN REPEAT GeneratedItem[4] := FORMAT(Option_Table.Option); // Insert new item NewItem.INIT; // NewItem [record variable of subtype Item] NewItem.NewItemNo := GeneratedItem[1]+GeneratedItem[2]+GeneratedItem[3]+GeneratedItem[4]; NewItem.INSERT(TRUE); UNTIL Option_Table.NEXT = 0; UNTIL Color_Table.NEXT = 0 UNTIL Style_Table.NEXT = 0; UNTIL Type_Table.NEXT = 0;
Hope this helps!0 -
While this doesn't answer your question exactly, have you considered using Non-stock items instead. If you create 10's of thousands of records for things that MIGHT be sold or purchased, then anything that uses the Item table will take longer. Instead, create them as non-stocks, and when necessary, convert to Item. You might have to do something with the Item Nos. to meet your requirement, but surely is a better approach.0
-
I believe i have resolved this. I will post the code once tested and signed off.Steve0
-
What's the difficulty on this: it's just repeats inside repeats to obtain the 180 different items from it.
var vtype : code[10] dimension [3]; vstyle: code[10] dimension[5]; vcolor: code[10] dimension[5]; voption: code[10] dimension[3]; Auxcounters integer dimension 4; vPartNo: code[20]; BEGIN CLEAR (AuxCounters); CLEAR (Vtype); vType[1] := '1'; vType[2] := '2'; vType[3] := '3'; VStyle[1] := 'A01'; // ..... ETC... initialize all the values on the arrays for the info you need to use for the part no. for each of the variables, vcolor, voption.. Auxcounters[1] := 1; REPEAT Auxcounters[2] := 1; REPEAT Auxcounters[3] := 1; REPEAT Auxcounters[4] := 1; REPEAT vPartNo := COPYSTR(VType[Auxcounters[1]] + vStyle[Auxcounters[2]] + vColor[Auxcounters[3] + vOption[AuxCounters[4]],1,MAXSTRLEN(VPartNo)); clear (vItem); vItem.INIT; VItem.TRANSFERFIELDS(Reference_Item_variable_to_copy_default_values_from); vItem."No." := vPartNo; vItem.INSERT(TRUE); Auxcounters[4] += 1; UNTIL (Auxcounters[4] > 5); Auxcounters[3] += 1; UNTIL (Auxcounters[3] > 5); Auxcounters[2] += 1; UNTIL (Auxcounters[1] > 5); Auxcounters[1] += 1; UNTIL (AuxCounters[1] > 3); END;
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions