CRN/CID Generator

asmilie2b
Member Posts: 122
We need to have NAV print a CID number generated from the document number. This is using algorithm MOD10 V01 or something compatible. I wonder if there are any resources available on doing this purely in C/AL if possible, or perhaps in .NET that anyone has encountered?
Bruce Anderson
0
Answers
-
I did find this discussion here:
viewtopic.php?f=23&t=48786&hilit=Luhn+algorithm
However the calculation there was slightly different to what I need for the service I have to comply with, BPay.
Below is the code i came up with. It accepts a string of the CRN to add a checksum, calculates and adds the checksums and then returns it.GenerateChecksum(CRN : Text) : Text CLEAR(TotalChars); CLEAR(TempInteger); // Find the sum of the multiplied digits FOR i := STRLEN(CRN) DOWNTO 1 DO BEGIN j += 1; EVALUATE(TempInteger,COPYSTR(CRN,i,1)); IF (j MOD 2) <> 0 THEN BEGIN // Only every 2nd character starting from very right CASE TempInteger OF 1: TempInteger := 2; 2: TempInteger := 4; 3: TempInteger := 6; 4: TempInteger := 8; 5: TempInteger := 1; 6: TempInteger := 3; 7: TempInteger := 5; 8: TempInteger := 7; 9: TempInteger := 9; END; END; TotalChars += TempInteger; END; // Final calculations TempInteger := TotalChars MOD 10; TempInteger := 10 - TempInteger; CRN := CRN + FORMAT(TempInteger); EXIT(CRN);
Bruce Anderson0
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