The CHKDAT2 command provides a method of performing validation
against a date field. Not only must the date be valid, but optional
parameters allow you to perform some range checking on the value
entered. Any system supported date format may be used.
A typical command would ensure that the date entered is within 365
days after today.
CHKDAT2 DATE(&DATE) DATFMT(*YYMMDD) DAYLORNG(0)
DAYHIRNG(+365)
Since the date format was specified as *YYMMDD, the value for &DATE
must be in a yymmdd format.
The following escape messages may be monitored for:
CPF0555 Invalid date format
TAA9883 Date not in current year
TAA9884 Date not in ranges provided
Comparison with CHKDAT
----------------------
CHKDAT requires the input date to be in *JOB format. It sends
CPF9898 regardless of the error condition.
Calling the CPP directly
------------------------
The CPP may be called directly. The following RPG III code shows an
example which is in a format ready to be copied:
C CALL 'TAADATYC' Call
C PARM INPDAT 10 Input date
C PARM '*JOB' DATFMT 8 Date format
C PARM -365 LORNG 50 Low range
C PARM +365 HIRNG 50 High range
C PARM '*YES' CURYR 4 Current yr
Command parameters *CMD
------------------
DATE The date to be checked. Any system supported format
may be entered, but it must agree with the DATFMT
specified.
DATFMT The format of the value in the DATE parameter. All
of the standard system date formats are supported.
For a full list, prompt for the allowed values.
DAYLORNG The low range in days from the current date. For
example, if the date should not be in the past,
enter 0. The default is -365 days meaning the date
must be within the last year. You may also enter a
plus value such as 7 meaning the date must be at
least 7 days greater than the current date.
*MAX may be specified to allow any value.
DAYHIRNG The high range in days from the current date. For
example, if the date should not be in the future,
enter 0. The default is +365 days meaning within
the following year. You may also enter a minus
value such as -7 meaning the date must be at least 7
days less than the current date.
*MAX may be specified to allow any value.
CURYEAR A *YES/*NO value for whether to ensure the year
entered is the same as the current year. *NO is the
default meaning that any year may be entered.
A *YES requires that the year of the date entered
match the current year.
Restrictions
------------
The tool uses ADDDAT2 which has some restrictions on days to be added
or subtracted (such as the number of days must be plus or minus
within 35000 days.
Prerequisites
-------------
The following TAA Tools must be on your system:
ADDDAT2 Add date
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ----- --------- ---------- -----------
CHKDAT2 *CMD TAADATY QATTCMD
TAADATYC *PGM CLP TAADATYC QATTCL