To find the verification digit for a given value.
Aravindh_Navision
Member Posts: 258
Hai Friends,
I need to find the verification digit to the following value: 3070841326319000361243033388633240620117 (Length - 39 char)
Logic for finding the Verification Digit:
1. Sum odd positions [3, 7, 8, 1, 2, 3, 9, 0, 3, 1, 4, 0, 3, 8, 6, 3, 4, 6, 0, 1]. (SumOdd = 72)
2. Multiply SumOdd * 3. (Mult = 72 * 3 = 216)
3. Sum even positions [0, 0, 4, 3, 6, 1, 0, 0, 6, 2, 3, 3, 3, 8, 3, 2, 0, 2, 1]. (SumEven = 47)
4. Sum = Mult + SumEven, (Sum = 216 + 47 = 263)
5. Verification digit 7. (We need to add the integer value 7 to 263 so the nearest higher value which should divisible by 10 and the remainder remains 0.)
To find the lowest number (verification digit):
VeriDigit = 10 - (Sum - (int(Sum/10) * 10))
VeriDigit = 10 - (263 -(int(263/10) * 10))
VeriDigit = 10 - (263 - (26 * 10))
VeriDigit = 10 - (263 - 260) = 10 - 3
VeriDigit = 7 (Answer)
Can anyone please help me in solving this in NAV?
Thanks in advance.
I need to find the verification digit to the following value: 3070841326319000361243033388633240620117 (Length - 39 char)
Logic for finding the Verification Digit:
1. Sum odd positions [3, 7, 8, 1, 2, 3, 9, 0, 3, 1, 4, 0, 3, 8, 6, 3, 4, 6, 0, 1]. (SumOdd = 72)
2. Multiply SumOdd * 3. (Mult = 72 * 3 = 216)
3. Sum even positions [0, 0, 4, 3, 6, 1, 0, 0, 6, 2, 3, 3, 3, 8, 3, 2, 0, 2, 1]. (SumEven = 47)
4. Sum = Mult + SumEven, (Sum = 216 + 47 = 263)
5. Verification digit 7. (We need to add the integer value 7 to 263 so the nearest higher value which should divisible by 10 and the remainder remains 0.)
To find the lowest number (verification digit):
VeriDigit = 10 - (Sum - (int(Sum/10) * 10))
VeriDigit = 10 - (263 -(int(263/10) * 10))
VeriDigit = 10 - (263 - (26 * 10))
VeriDigit = 10 - (263 - 260) = 10 - 3
VeriDigit = 7 (Answer)
Can anyone please help me in solving this in NAV?
Thanks in advance.
0
Comments
-
Create a function and pass the Sum value and get return value as
EXIT(Sum - (int(Sum/10) * 10))
0 -
Thanks Mohana. How to operate with the given 39 char length value? This contains 2 types of logic. How to proceed with the first one?0
-
from where do you get that value? based on that you can calculate the first 4 steps..right?0
-
Actually I am getting Ptxt_String value from the combination of few fields. Could you please correct where I am missing out the logic in the below lines of coding?
Ptxt_String = 3070841326319000361243033388633240620117 (39 char)
Ltxt_resultstring, Ltxt_resultstringO, Ptxt_String are text varialbles and others are integer variablesCLEAR(LInt_total); CLEAR(LInt_totalO); CLEAR(LInt_TempInt); CLEAR(LInt_TempIntO); FOR a := 1 TO STRLEN(Ptxt_String) DO BEGIN EVALUATE(LInt_TempInt,COPYSTR(Ptxt_String,a,1)); EVALUATE(LInt_TempIntO,COPYSTR(Ptxt_String,a,1)); IF (a MOD 2) <> 0 THEN BEGIN LInt_TempInt *= 3; Ltxt_resultstring := Ltxt_resultstring + FORMAT(LInt_TempInt); END ELSE IF (a MOD 2) = 0 THEN BEGIN LInt_TempIntO *= 1; Ltxt_resultstringO := Ltxt_resultstringO + FORMAT(LInt_TempIntO); END; END; EVALUATE(LInt_TempInt,COPYSTR(Ptxt_String,STRLEN(Ptxt_String),1)); EVALUATE(LInt_TempIntO,COPYSTR(Ptxt_String,STRLEN(Ptxt_String),1)); Ltxt_resultstring := Ltxt_resultstring + FORMAT(LInt_TempInt); Ltxt_resultstringO := Ltxt_resultstringO + FORMAT(LInt_TempIntO); FOR a := 1 TO STRLEN(Ltxt_resultstring) DO BEGIN EVALUATE(LInt_TempInt,COPYSTR(Ltxt_resultstring,a,1)); LInt_total += LInt_TempInt; END; FOR a := 1 TO STRLEN(Ltxt_resultstringO) DO BEGIN EVALUATE(LInt_TempIntO,COPYSTR(Ltxt_resultstringO,a,1)); LInt_totalO += LInt_TempIntO; END; LInt_FinalTotal := LInt_total + LInt_totalO;0 -
message('%1',strchecksum('307084132631900036124303338863324062011', '313131313131313131313131313131313131313')) ;this returns your '7'
0 -
STRLEN is 40 not 39 in above exampleAravindh_Navision wrote:I need to find the verification digit to the following value: 3070841326319000361243033388633240620117 (Length - 39 char)
[0, 0, 4, 3, 6, 1, 0, 0, 6, 2, 3, 3, 3, 8, 3, 2, 0, 2, 1,7]Aravindh_Navision wrote:3. Sum even positions [0, 0, 4, 3, 6, 1, 0, 0, 6, 2, 3, 3, 3, 8, 3, 2, 0, 2, 1]. (SumEven = 47)
Here Sum is 54
Here Sum = 216 + 54 = 270Aravindh_Navision wrote:4. Sum = Mult + SumEven, (Sum = 216 + 47 = 263)
[/quote]
Try this codePtxt_String := '3070841326319000361243033388633240620117'; CLEAR(LInt_total); CLEAR(LInt_totalO); CLEAR(LInt_TempInt); CLEAR(LInt_TempIntO); FOR a := 1 TO STRLEN(Ptxt_String) DO BEGIN EVALUATE(LInt_TempInt,COPYSTR(Ptxt_String,a,1)); EVALUATE(LInt_TempIntO,COPYSTR(Ptxt_String,a,1)); IF (a MOD 2) <> 0 THEN BEGIN LInt_TempInt *= 3; Ltxt_resultstring := Ltxt_resultstring + LInt_TempInt; END ELSE IF (a MOD 2) = 0 THEN BEGIN LInt_TempIntO *= 1; Ltxt_resultstringO := Ltxt_resultstringO + LInt_TempIntO; END; END; Message('%1',Ltxt_resultstring); Message('%1',Ltxt_resultstringO); LInt_FinalTotal := Ltxt_resultstringO + Ltxt_resultstring; Message('%1',LInt_FinalTotal);
Where Ltxt_resultstring and Ltxt_resultstringO also integers..0 -
Mohana,
Sorry I missed to delete the last character in the given value. Yeah I will try with your code and let know about the result. Thanks you very much for your effort.
MBerger,
STRCHECKSUM function worked for me. Thank you very much. Let me try with Mohana's modified code too.
Thanks.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
- 322 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
