TAA Tools
CHKVAL          CHECK VALUE                            TAACLTK

The  Check Value  command  is  intended for  the  case where  the  user
inputs  a  value to  a  CL program  and  the value  must  be validated.
CHKVAL  offers  several checking  options  that vary  depending  on the
type requested.   Special values  are also  supported.  Standard  error
text may be used to simplify the explanation of any errors.

While CHKVAL is intended  for use in a CL program, it  may be tested in
an interactive environment.

A  typical  example is  to check  the  value of  a  field named  AMT to
ensure that it is in a range of 1 to 5000.

             CHKVAL     VALUE(&VALUE) TYPE(*DEC) DECLORNG(1) +
                          DECHIRNG(5000) VALNAME('AMT')

If the  &VALUE  is  a  decimal  value within  the  range,  the  command
completes normally without a completion message.

If  the &VALUE  is out  of  the range,  TAA9893  is sent  as an  escape
message with default text which would state:

         'Invalid value nnnn for AMT.  The *DEC value must
          be in a range of 1 to 5000'

Another  example is to check  a field which  can be either a  name or a
list of special values:

             IF         (&FLDNAM *EQ 'USER') DO /* Check name */
             CHKVAL     VALUE(&VALUE) TYPE(*NAME) +
                          LIST(*SYSOPR *PGMR) VALNAME('USER')

If the &VALUE  is invalid, TAA9893  is sent as an  escape message  with
default text which would state:

        'For USER, the *NAME value must be a valid name or one of
           the following - *SYSOPR *PGMR'

Or you may want to check for a boolean value (*EQ, *NE ...  *GE).

             IF         (&FLDNAM *EQ 'OPER') DO /* Check operator */
             CHKVAL     VALUE(&VALUE) TYPE(*BOOLEAN) +
                          VALNAME('OPER')

Types and valid entries
-----------------------

                        Allow          Length   Range
Type           List     Blank   Full   Check    Check
----           ----     -----   ----   ------   -----

*CHAR           N         Y      Y       Y        N
*DEC            Y         Y      Y       Y        Y
*NAME           Y         Y      Y       Y        N
*GENERIC        Y         Y      N       Y        N
*LIST           Y         Y      N       N        N
*DATE           Y         Y      N       N        N
*TIME           Y         Y      N       N        N
*YESNO          N         N      N       N        N
*EQNE           N         N      N       N        N
*BOOLEAN        N         N      N       N        N
*BOOLEAN2       N         N      N       N        N

If ALWBLK(*YES) is used,  a blank value will cause  a normal completion
before (no other checking is performed).

If a range check is used, LENCHK(*NONE) must be specified.

For  *NAME and  *GENERIC, the value  may not  exceed 10  characters and
must contain valid characters for a system name.

CHKVAL escape messages you can monitor for
------------------------------------------

      TAA9893    Validity checking failed

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

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

   VALUE         Up to 15 characters may be entered.

                 When  entering  the  CHKVAL  command  interactively, a
                 blank value should be  entered as ' '.   When entering
                 the  CHKVAL  command  in  a  CL  program,  a  variable
                 containing blanks is not an error.

                 For  TYPE(*DEC),  the  value  may  contain  a  leading
                 minus sign if  ALWMINUS(*YES) is  specified.   Decimal
                 positions are invalid in the value.

   TYPE          The type of  value to be checked.   Some types support
                 options  for LIST, ALWBLK,  FULL, LENCHK,  or a range.
                 See the  previous chart  for the  valid  combinations.
                 TYPE must be one of the following:

                   *CHAR        Any character value
                   *DEC         Any decimal value
                   *NAME        A valid name
                   *GENERIC     A valid name or generic name
                   *LIST        Any value in the specified list
                   *DATE        A valid date
                   *TIME        A valid time
                   *YESNO       A *YES or *NO
                   *EQNE        An *EQ or *NE
                   *BOOLEAN     An *EQ, *NE, *GE, *LE, *GT, or *LT
                   *BOOLEAN2    An *EQ, *NE, *GE, *LE, *GT, *LT,
                                  or *CT (*CT = Contains)

                 TYPE(*DEC) does  not  allow decimal  positions or  any
                 other  separators.   A  leading  minus  sign is  valid
                 with ALWMINUS(*YES).

                 *DATE supports any format allowed by CVTDAT.

                 *TIME allows either a 6 or 8 byte value.

                 *NAME  and *GENERIC  consider a value  greater than 10
                 characters to  be  invalid.   The value  must  contain
                 valid characters for a system name.

   LIST          Up  to  100  entries  of  15 characters  each  may  be
                 entered  that will be checked against  the value.  The
                 default  is  *NOVALUES  meaning  no  values  will   be
                 checked.    See the  chart  for  when  a list  may  be
                 specified.

   ALWBLK        A *YES/*NO parameter for whether blanks may exist.

                 *NO  is  the  default meaning  a  blank  value is  not
                 valid.

                 *YES may be specified  to allow a blank  value.  If  a
                 blank  value  is   entered,  any  other   checking  is
                 bypassed  and  the command  completes  normally.   See
                 the chart for when *YES may be specified.

   FULL          A  *YES/*NO  parameter  for  whether  any  blanks  may
                 exist.

                 *NO is  the  default meaning  some  characters may  be
                 blank.

                 *YES  may be specified  to ensure  the field  is full.
                 A  LENCHK value must be specified.   See the chart for
                 when *YES may be specified.

   LENOPR        The type  of check for  the length  to be  made.   The
                 value is ignored if LENCHK(*NONE) is specified.

                 *EQ is  the default.  *NE,  *GT, *LT, *GE, or  *LE may
                 be specified.

                 For  example, if  a  value must  be 5  bytes  or less,
                 specify LENCHK(5) and LENOPR(*LE).

   LENCHK        Whether a check of the  length of the value should  be
                 made.

                 *NONE  is the  default.   If  *NONE  is specified  the
                 value of LENOPR is ignored.

                 A value from 1 to 15 may be entered.

   ALWMINUS      A  *YES/*NO value  for whether  the value  entered can
                 contain a leading minus sign.

                 *NO is the default.

                 *YES  may be specified  to allow a  leading minus sign
                 for TYPE(*DEC).  *YES  may not be used for  other TYPE
                 values.

   DECLORNG      A low range to be checked for a decimal value.

                 *NONE is  the default meaning no range  check is made.

                 A  value  of up  to  15 digits  may be  entered.   The
                 value  must   be  between   -999,999,999,999,998   and
                 999,999,999,999,999.     If   a   DECLORNG  value   is
                 entered, a DECHIRNG value must also be entered.

   DECHIRNG      A high range to be checked for a decimal value.

                 *NONE is  the default meaning no  range check is made.

                 A value  of up  to  15 digits  may  be entered.    The
                 value  must   be   between  -999,999,999,999,998   and
                 999,999,999,999,999.     If   a   DECHIRNG   value  is
                 entered, a DECLORNG value must also be entered.

   VALNAME       The  name of the value to  appear in the error text if
                 ERRORTXT(*STD) is  specified.   The  default is  *NONE
                 meaning ERRORTXT must be specified.

   ERRORTXT      The error  text to be  provided.  *STD is  the default
                 in which case standard text is provided such as

                     Invalid value vvv for xxx.
                     The *yyy value must be *YES or *NO.

                 where  vvv  is  the value  entered,  xxx  is  the name
                 provided in  the VALNAME  parameter  and *yyy  is  the
                 TYPE.

                 Specific  error text  may  be  entered in  which  case
                 VALNAME(*NONE) must be used.


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

None.

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

The following TAA Tools must be on your system:

     CHKNAM          Check name
     CVTTIM          Convert time
     EDTVAR          Edit variable
     EXTLST          Extract list
     RTVVALA         Retrieve value attributes
     SNDESCINF       Send escape information
     SNDESCMSG       Send escape message

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

None, the tool is ready to use.

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

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

   CHKVAL        *CMD                   TAACLTK       QATTCMD
   TAACLTKC      *PGM       CLP         TAACLTKC      QATTCL
					

Added to TAA Productivity tools January 15, 2010


Home Page Up to Top