Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

CR10 - Check Digit with Weight Using 7,5,3,2

Posted on 2013-02-07
3
551 Views
Last Modified: 2013-02-08
Hello:

I need help with the formula attached - I need to change it from Calculating "Double Every Second Digit" to using the 7,5,3,2 Check Digit Weight, repetition starting from the first number on the left of the scan line.  

Any ideas would be great.  I'm at a loss on how to do this at this point.  

Thank you!

** Attached Document Contains Example from Bank and the original formula.
Check-Digit-Weights.docx
0
Comment
Question by:eleale
3 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38866471
Are all the numbers the same length? (19 digits in the example)

WHere does the answer 214 come from?  The sum of the products is 206.

Can you confirm that the field containing the number is being seen by Crystal as a text field.
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 38866874
Actually the sum of the products is 216  (127 + 45 = 172 not 162)
Here is the code to get the check digit for the give string

Local StringVar ScanNumber := '544969302100002500';
Local NumberVar Array Multipliers := [7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2];
Local NumberVar CheckDigitTotal;
Local NumberVar Index;
Local NumberVar ConstantValue := 8;

CheckDigitTotal := 0;

For Index := 1 to Length(ScanNumber) do
   CheckDigitTotal := CheckDigitTotal + Val(ScanNumber[Index]) * Multipliers[index];

CheckDigitTotal := CheckDigitTotal + ConstantValue;
CheckDigitTotal MOD 10

Open in new window



For a string from the database use
Local StringVar ScanNumber;
Local NumberVar Array Multipliers := [7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2,7,5,3,2];
Local NumberVar CheckDigitTotal;
Local NumberVar Index;
Local NumberVar ConstantValue := 8;

ScanNumber := {Yourfield};
CheckDigitTotal := 0;

For Index := 1 to Length(ScanNumber) do
   CheckDigitTotal := CheckDigitTotal + Val(ScanNumber[Index]) * Multipliers[index];

CheckDigitTotal := CheckDigitTotal + ConstantValue;
CheckDigitTotal MOD 10

Open in new window


The code will handle a 32-digit numeric string.  If you need more just exted the Multiplier array with more 7532's

You can change the constant as desired or even set it to a database field or parameter


mlmcc
0
 

Author Closing Comment

by:eleale
ID: 38868322
Thank you!!!  This worked perfectly.  

Awesome!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question