The Check Name Field 2 command allows you to check name and address
values for proper case such as 'THomas ThuMb' or 'Thomas thumb' and
returns a value of 'Thomas Thumb'. The return value is ensured to
have the first letter of each word capitalized and the remaining
letters to be lower case.
An optional return value allows you to determine if any differences
exist between the input and return values.
CHKNAMFLD2 uses some of the functions of the CHKNAMFLD tool which
provides a similar function for all records in a file for a named
field. CHKNAMFLD2 operates on a single value.
A list of small words such as 'and', 'or', etc may be left in lower
Only the English language is supported in the supplied code. See the
later section on 'Non-English languages'.
Because business names have a lot of acronyms (eg 'ABC Co.' which
would cause a return value of 'Abc Co.'), not every name or address
should be changed.
A typical series of commands would be:
DCL &RTNVAL *CHAR LEN(50)
DCL &RTNCHG *CHAR LEN(4)
CHKNAMFLD2 INPVAL(xxx) RTNVAL(&RTNVAL) RTNCHG(&RTNCHG)
IF (&RTNCHG *EQ '*DIFF') DO /* Differs */
/* Your processing of different values */
ENDDO /* Differs */
Your processing might check the RTNCHG value and if *YES could prompt
both values to an operator and request which one should be used.
** First letter of each word must be capitalized. A blank or a
single quote determines the word delimiter.
** All other letters in a word are lower case. See the
exceptions discussed later for 'Mc' and 'Mac'.
** Exceptions are made for small words such as 'the', 'and', etc
which are left in lower case. An exception is also made for
the first word to allow a name such as 'The Best Inc.' to
appear with a capitalized first letter even though 'the' is in
the small word list.
Names with embedded capitals
The technique used determines the beginning of a word by a blank or a
single quote. Checking for a single quote allows a name like O'Neil
to be be properly handled.
However, some names have embedded capitals such as 'VanHoeven. This
would be returned as 'Vanhoeven'. If the name exists as 'Van Hoeven'
it would be properly checked.
An exception is made for names that begin with 'Mc' or 'Mac' such as
McKnight or MacIntosh. If the letters 'Mc' or 'Mac' are found, it is
assumed that the next character is correct (regardless of the case).
Note that the case must be 'Mc' or 'Mac' for this to occur.
The first letter of a word is ensured to be upper case using the
a - i (X'81' - X'89') are folded to A - I (X'C1' - X'C9')
j - r (X'91' - X'99') are folded to J - R (X'D1' - X'D9')
s - z (X'A2' - X'A9') are folded to S - Z (X'E2' - X'E9')
The following letters of a word are ensured to be lower case using
A - I (X'C1' - X'C9') are folded to a - i (X'81' - X'89')
J - R (X'D1' - X'D9') are folded to j - r (X'91' - X'99')
S - Z (X'E2' - X'E9') are folded to s - z (X'A2' - X'A9')
Any other characters (such as digits) would be left as is.
The following small words will be kept in lower case:
unless they appear at the beginning of the field such as 'The Best
The data for the small words is held in the TAADBKXP file in
TAASECURE. This is the same file as used by the CHKNAMFLD tool. As
an *ALLOBJ user, you may add or subtract words in this file by
The words are entered twice such as:
The capitalized version is the way the word would appear if the
SMALLWORDS option was not requested. The lower case version is the
way the word will be changed to. You may enter up to 100 words where
each word may be 7 characters or less.
Both versions of each word must be the same length or an error will
The TAADBLIR program (part of CHKNAMFLD2) may be changed to allow for
additional or different character transformations. Use:
This will copy the source to QATTxxx source files in TAATOOL. Use a
source editor for member TAADBLIR in file QATTRPG in TAATOOL. Scan
for TRANSFORM and see how the code converts various characters. The
ZONE field should be set to allow the zone of the character to
transform to. For example, the a-i hex values of X'81'-X'89' use the
zone of the letter 'A' (X'C1') to transform the character.
When coding is complete, enter:
CRTTAATOOL TOOL(CHKNAMFLD2) SRCLIB(TAATOOL)
This will re-create the required objects.
The TAADBKXP file in TAASECURE holds the small words that do not
follow the normal rules. See the previous section on 'Small words'
and change as required.
CHKNAMFLD2 escape messages you can monitor for
TAA9891 The INPVAL is all blank,
Escape messages from based on functions will be re-sent.
Command parameters *CMD
INPVAL The input value to be checked. Up to 50 bytes may
If a name has an apostrophe in it such as O'Neil, it
must be doubled as O''Neil. See the TAA CHKAPOST
command for a method of doubling.
SMALLWORDS A *YES/*NO option for the special handling of small
words such as 'and', 'or'.
*YES is the default to cause these words to be left
in lower case (the first letter will not be
capitalized). An exception is made for the first
letter in a name to allow for names such as 'The
*NO may be specified to prevent any special
treatment of small words.
See the previous documentation on what small words
are provided by default and how to modify the list.
RTNVAL The return value which may differ. This is an
optional return value that if used must be specified
as *CHAR LEN(50).
RTNCHG A return value of *SAME or *DIFF that assists in
determining if the return value differs from the the
input value. *DIFF is returned if the values
differ. *SAME is returned if the values are the
same. This is an optional return value that if used
must be specified as *CHAR LEN(7).
** Only the characters for the English language are provided for
in the supplied code.
The following TAA Tools must be on your system:
CHKNAMFLD Check name field
SNDESCINF Send escape information
SNDESCMSG Send escape message
None, the tool is ready to use.
Objects used by the tool
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
CHKNAMFLD2 *CMD TAADBLI QATTCMD
TAADBLIC *PGM CLP TAADBLIC QATTCL
TAADBLIR *PGM RPG TAADBLIR QATTRPG
The TAADBKXP file exists in library TAASECURE to hold the small words
that may be retained in lower case.