{"title":"Text.StrCheckSum(Text [, Text] [, Integer]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/text/text-strchecksum-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-strchecksum-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-strchecksum-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Calculates a checksum for a string that contains a number.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"Text.StrCheckSum(Text [, Text] [, Integer]) Method","slug":"textstrchecksumtext-text-integer-method","at":0,"chars":3327},{"level":2,"title":"Syntax","slug":"syntax","at":512,"chars":187},{"level":2,"title":"Parameters","slug":"parameters","at":699,"chars":624},{"level":2,"title":"Return Value","slug":"return-value","at":1323,"chars":93},{"level":2,"title":"Example 1","slug":"example-1","at":1416,"chars":586},{"level":2,"title":"Example 2","slug":"example-2","at":2002,"chars":1193},{"level":2,"title":"Related information","slug":"related-information","at":3195,"chars":132}],"text":"# Text.StrCheckSum(Text [, Text] [, Integer]) Method\n> Version: _Available or changed with runtime version 1.0._\nCalculates a checksum for a string that contains a number. If the source is empty, 0 is returned. Each char in the source and in the weight must be a numeric character 0-9, otherwise an exception is thrown. If the WeightString parameter is shorter then the source, it is padded with '1' up until the length of source. If the WeightString parameter is longer than the source, an exception is thrown.\n## Syntax\n```al\nCheckNumber :=   Text.StrCheckSum(String: Text [, WeightString: Text] [, Modulus: Integer])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nString\nType: text-data-type\nThis string contains the number for which you want to calculate a checksum. You can only enter the numeric characters 0-9 in this string. If you enter anything else, a run-time error will occur. If String is empty, 0 is returned.\n*[Optional] WeightString*\nType: text-data-type\nThis string contains numbers that you want to use as weights when calculating the checksum. The default value is a string that contains STRLEN(String) '1'-characters.\n*[Optional] Modulus*\nType: ../integer/integer-data-type\nThe number that you want to use in the checksum formula. The default value is 10.\n## Return Value\nCheckNumber\nType: ../integer/integer-data-type\nThe resulting checksum value.\n## Example 1\nThis example shows how to use the StrCheckSum method to calculate a checksum.\n```al\nvar\n    StrNumber: Text[30];\n    Weight: Text[30];\n    Modulus: Integer;\n    Text000: Label 'The number: %1\\\\';\n    Text001: Label 'has the checksum: %2';\nbegin\n    StrNumber := '4378';\n    Weight := '1234';\n    Modulus := 7;\n    CheckSum := StrCheckSum(StrNumber, Weight, Modulus);\n    Message(Text000 + Text001, StrNumber, CheckSum);\nend;\n```\nThe formula is:\n\\(7 - \\(4x1 + 3x2 + 7x3 + 8x4\\) MOD 7\\) MOD 7=0\nThe message window displays the following:\nThe number: 4378\nhas the checksum: 0\n## Example 2\nThis example shows how to use the StrCheckSum method to calculate a modulus 10 checksum for a bar code.\nThe StrCheckSum method can be used to calculate checksums for 13- and 8-digit European Article Number \\(EAN\\) and EAN-compatible bar codes such as a Universal Product Code \\(UPC\\) or Japanese Article Number \\(JAN\\).\nA 13-digit EAN code has the following format:\n1. The 12 digits in positions 13 to 2 are used to calculate the checksum at position 1.\n2. Starting with position 2, all even values are totaled. The result is then multiplied by three. This value is called Even.\n3. Starting with position 3, all odd values are totaled. The result is called Odd.\n4. Total=Even + Odd.\n5. The modulus 10 checksum is then \\(10 - Total MOD 10\\) MOD 10.\n```al\nvar\n    StrNumber: Text[30];\n    Weight: Text[30];\n    Modulus: Integer;\n    Text000: Label 'The EAN code: %1\\\\';\n    Text001: Label 'has the checksum: %2';\nbegin\n    StrNumber := '577622135746';\n    Weight := '131313131313';\n    CheckSum := StrCheckSum(StrNumber, Weight);\n    Message(Text000 + Text001, StrNumber, CheckSum);\nend;\n```\nThe message window displays the following:\nThe EAN code: 577622135746\nhas the checksum: 3\n## Related information\ntext-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}