sysLib.verifyChkDigitMod10

The system function sysLib.verifyChkDigitMod10 verifies a modulus-10 check digit in a character item that begins with a series of integers.


sysLib.verifyChkDigitMod10 syntax diagram

input

A character item that begins with a series of integers. The item include an additional position for the check digit, which is immediately to the right of the other integers.

checkLength

An item that contains the number of characters that you want to use from the input item, including the position used for the check digit. This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.

result

An item that receives one of two values:

  • 0, if the calculated check digit matches the value in input

  • 1, if the calculated check digit does not match that value

This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.

You can use sysLib.verifyChkDigitMod10 in a function-invocation statement; or as an item validator in a text form.

Example

In the following example, myInput is an item of type CHAR and contains the value 1734284; myLength is an item of type SMALLINT and contains the value 7; and myResult is an item of type SMALLINT:

  sysLib.verifyChkDigitMod10 (myInput, myLength, myResult);

An algorithm is used to derive the modulus-10 check digit, and in all cases the number at the check-digit position is not considered; but when the algorithm is complete, the calculated value is compared with the number at the check-digit position.

The algorithm is described in relation to the example values:

  1. Multiply the units position of the input number by 2 and multiply every alternate position, moving right to left, by 2:
      8 x 2 = 16
      4 x 2 = 8
      7 x 2 = 14

  2. Add the digits of the products (16814) to the input-number digits (132) that were not multiplied by 2:
      1 + 6 + 8 + 1 + 4 + 1 + 3 + 2 = 26   

  3. To get the check digit, subtract the sum from the next-highest number ending in 0:
      30 - 26 = 4

    If the subtraction yields 10, the check digit is 0.

In this example, the calculated check digit matches the value in the check-digit position, and the value of myResult is 0.

Related reference
Validation properties