TAA Tools
CLCMOD11        CALCULATE MODULUS 11                   TAACLRA

The Calculate  Modulus 11 command  calculates the  value for a  Modulus
11 Self-Check  Digit.  The  command returns a value  for the self-check
digit  which is  intended to be  added to a  number such  as a customer
number.  DDS supports the  CHECK(M11) keyword for a field to  assist in
ensuring  the number  is keyed  correctly.   Some  input values  cannot
produce  a Modulus 11  self-check digit  and an escape  message will be
sent.

Self-check digits  are  commonly  used  when entering  values  such  as
customer   numbers  to   minimize   errors  caused   by  miskeying   or
transposing digits.

The  CLCMOD11 command creates  the self-check  digit.  For  example, if
your customer  number is  5 digits  without the  self-check digit,  the
following  CL program  using CLCMOD11  would  calculate the  self-check
digit and return a 6 digit customer number.

             PGM        PARM(&CUST5 &CUST6)
             DCL        &CUST5 *CHAR LEN(5)
             DCL        &CUST6 *CHAR LEN(6)
             DCL        &DIGIT *CHAR LEN(1)
             CLCMOD11   INPUT(&CUST5) MOD11DGT(&DIGIT)
             MONMSG     MSGID(TAA9893) EXEC(DO) /* Invalid input */
                        /*                                       */
                        /*    Your handling of invalid input     */
                        /*                                       */
             ENDDO      /* Invalid input value */
             CHGVAR     &CUST6 (&CUST5 *CAT &DIGIT)
             ENDPGM

The 6 digit number becomes the customer number.

See  the DDS manual  for a  discussion of  how the self-check  digit is
calculated.

Note  that some values will not  generate a valid Modulus 11 self-check
digit.  There is no solution other than to use a different value.

Checking the value without using DDS
------------------------------------

You can use CLCMOD11  to check a value also.   Just strip off  and save
off  the  digit position,  use  CLCMOD11  to  calculate the  self-check
digit, and them compare the calculated digit to the saved version.

CLCMOD11 escape messages you can monitor for
--------------------------------------------

      TAA9891    The input value cannot be all blanks.
      TAA9892    The input value must only contain digits.
      TAA9893    A Modulus 11 self-check digit cannot be calculated.

Escape messages from based on functions will be re-sent.

Command parameters                                    *CMD
------------------

   INPUT         The  input value  without the  self-check digit.   The
                 value cannot be all blanks  and must have only  digits
                 and  trailing  blanks.    Up   to  31  digits  may  be
                 entered.

                 Some  input  values will  not  generate  a Modulus  11
                 self-check  digit.    If  such  a  value  is  entered,
                 TAA9893 is sent as an escape message.

   MOD11DGT      The self-check  digit to  be returned.   The  variable
                 must be declared as *CHAR LEN(1).

Restrictions
------------

Because the  command returns a  variable, it may  only be used  in a CL
program.

Prerequisites
-------------

The following TAA Tools must be on your system:

     EDTVAR          Edit variable
     SNDESCMSG       Send escape message

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

   Object        Type    Attribute      Src member    Src file
   ------        ----    ---------      ----------    ----------

   CLCMOD11      *CMD                   TAACLRA       QATTCMD
   TAACLRAC      *PGM       CLP         TAACLRAC      QATTCL
					

Added to TAA Productivity tools January 15, 2002


Home Page Up to Top