GS1 utilities
Check digits
GS1 identifiers such as GTIN, SSCC and GLN end with a modulo 10 check digit. The following codes can be used to calculate and verify it. In all of them, the first parameter is the number to process, which can itself be a dynamic text, e.g. a database table column. Spaces in the number are ignored, but any other character than digits 0-9 is an error.
| Code | Description |
|---|---|
{GS1_CHECKDIGIT} | Prints only the check digit of the number. |
{GS1_ADDCHECKDIGIT} | Prints the number followed by its check digit. |
{GS1_NORMALIZE} | Takes a number that already ends with a check digit, verifies the check digit, and pads the number with leading zeros to the number of digits given by the second (mandatory) parameter. It is an error if the check digit is wrong, or if the number has more digits than requested. |
Examples
GTINs imported from other systems are often not in the form a barcode needs: the check digit may be missing, or the numbers may have different lengths. The GS1 codes are typically used to fix such data when it is read from a database table.
Adding a missing check digit
If the column GTIN contains GTIN-13 numbers without the check digit, {GS1_ADDCHECKDIGIT} completes them:
{GS1_ADDCHECKDIGIT;{TABLE;GTIN}}
GTIN column | Printed |
|---|---|
590123412345 | 5901234123457 |
400638133393 | 4006381333931 |
If only the check digit is needed, e.g. to print it separately next to the number, use {GS1_CHECKDIGIT;{TABLE;GTIN}} instead, which prints 7 and 1 for the rows above.
Normalizing GTINs of mixed lengths
If the column GTIN contains a mix of GTIN-8, GTIN-12 and GTIN-13 numbers, all including the check digit, {GS1_NORMALIZE} turns them into GTIN-14 numbers, as required by e.g. GS1 application identifier (01):
{GS1_NORMALIZE;{TABLE;GTIN};14}
GTIN column | Printed |
|---|---|
96385074 | 00000096385074 |
036000291452 | 00036000291452 |
4006381333931 | 04006381333931 |
4006381333932 | Error, since the check digit is wrong. |
Since the check digit is verified, a mistyped number in the table results in an error instead of a barcode with the wrong number.