How to split a record and format to string?

RosOmar
Member Posts: 7
Lets say we have a Code record with 3 digits. Based on first digit we would want to format to string?
Example:
001 = Lion
101 = Tiger
201 = Moth
Would appreciate any help.
Example:
001 = Lion
101 = Tiger
201 = Moth
Would appreciate any help.
0
Best Answer
-
Hi,
You can try below codeIf ItemVarient.findset then repeat String := COPYSTR(ItemVarient.Code, 1, 1); CASE String OF '1' : BEGIN Newtab.init; Newtab.code := '1'; Newtab.value := 'Black'; IF Newtab.inset THEN; END; END; until ItemVarient.next = 0;
0
Answers
-
Hi RosOmar,
I take it the records do not have the values you want to output stored on a field on the record?
I'm not really sure why you would want to do this but I don't know the context. You code do something like this, where Code var is just representing the record (I assume it's PK) -> get the 1st char -> hardcode the values in a case.
I don't really like this solution but a part of it might help. I would prefer to have the values on the record or linked in another table etc.Code := '100'; String := COPYSTR(Code, 1, 1); CASE String OF '1' : MESSAGE('Example');
Josh1 -
Josh,
Thanks for reply.
The Code var is indeed a record and the values too need to get linked to a table.
Basically we have a record from Item Variant table. Then based on 1st number, the record need to be converted/formated to, lets say Colour (1 = black, 2 = white etc), then this colour will be inserted to a different table.... So this new table will act as a translator.
Would appreciate further advice.
Thanks in advance.
0 -
Hi,
You can try below codeIf ItemVarient.findset then repeat String := COPYSTR(ItemVarient.Code, 1, 1); CASE String OF '1' : BEGIN Newtab.init; Newtab.code := '1'; Newtab.value := 'Black'; IF Newtab.inset THEN; END; END; until ItemVarient.next = 0;
0 -
Aniish thank you very much. This is it!!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