Here is the definition of the function from the c/side reference guide, I think it gives you all the info you need to use the function.
STRCHECKSUM (STRING)
Use this function to calculate a checksum for a string containing a number.
CheckNumber :=STRCHECKSUM(String[, WeightString] [, Modulud])
String
Data type: text constant or code
This string contains the number for which you want to calculate a checksum. You can only enter the numeric characters 0-9 in this string. Entering anything else will cause a run-time error.
WeightString
Data type: text constant or code
This string contains numbers you want the system to use as weights when calculating the checksum. The default value is a string containing STRLEN(String) ‘1’-characters.
You can only enter the numeric characters 0-9 in this string. Entering anything else will cause a run-time error.
If String is longer than WeightString, the system will concatenate a string containing STRLEN(String) - STRLEN(WeightString) ‘1’-characters to the end of WeightString. If WeightString is longer than String, a run-time error occurs.
Modulus
Data type: integer
The number you want to use in the checksum formula (see below). The default value is 10.
CheckNumber
Data type: integer
The checksum, which the system calculates using this formula:
Modulus - [i]WeightString[i]) MOD Modulus)) MOD Modulus
where n = STRLEN(String).
Example
These examples show how to use the STRCHECKSUM function.
Calculating a checksum:
StrNumber := ‘4378’;
Weight := ‘1234’;
Modulus := 7;
CheckSum := STRCHECKSUM(StrNumber, Weight, Modulus);
MESSAGE(Text000 + Text001, StrNumber, CheckSum);
Create the following text constants in the C/AL Globals window:
Text Constant
|
ENU Value
|
Text000
|
‘The number: %1’
|
Text001
|
‘has the checksum: %2’
|
STRCHECKSUM(‘4378’,‘1234’, 7) returns:
(7 - (4x1 + 3x2 + 7x3 + 8x4) MOD 7) MOD 7 = 0
The message window shows:
The number: 4378
has the checksum: 0
Calculating a modulus 10 checksum for a bar code:
The STRCHECKSUM function can be used to calculate checksums for 13- and 8-digit EAN (European Article Number) and EAN compatible bar codes such as UPC (Universal Product Code) or JAN (Japanese Article Number).
A 13-digit EAN code has this format:
-
The system uses the 12 digits in positions 13 to 2 to calculate the checksum at position 1.
-
Starting with position 2, the system totals all even values. It then multiplies the result by three. This value is called Even.
-
Starting with position 3, the system totals all odd values. The result is called Odd.
-
Total = Even + Odd.
-
The modulus 10 checksum is then: (10 - Total MOD 10) MOD 10.
Here’s how to use STRCHECKSUM to calculate this result:
StrNumber := ‘577622135746’;
Weight := ‘131313131313’;
CheckSum := STRCHECKSUM(StrNumber, Weight);
MESSAGE(Text000 + Text001, StrNumber, CheckSum);
Create the following text constants in the C/AL Globals window:
Text Constant
|
ENU Value
|
Text000
|
‘The EAN code: %1’
|
Text001
|
‘has the checksum: %2’
|
The message window shows:
The EAN code: 577622135746
has the checksum: 3