The convert date CL program allows a HLL program to access to the
CVTDAT CL command. The function is accessed only via a parameter
list. The parameters are the similar to that available on CVTDAT.
The typical use of the program is to allow a HLL language program to
convert a date field from the job format to a YYMMDD format.
Several programs are supported:
** TAADATFC converts 6 character dates to 6 character dates.
** TAADATFE converts any valid date format for the CVTDAT CL
command. Both the 'from' and 'to' dates must be specified as
10 character byte fields.
** TAADATFG is the same as TAADATFE but allows an additional
parameter for TOSEP.
The following is an example of TAADATFC (6 byte date fields)
C CALL 'TAADATFC' CVTDAT tool
C PARM DATE FRMDAT 6 From date
C PARM TODAT 6 To date
C PARM '*JOB ' FRMFMT 4 From format
C PARM '*YMD ' TOFMT 4 To format
The following is an example of TAADATFE (10 byte date fields)
C CALL 'TAADATFE' CVTDAT tool
C PARM DATE FRMDAT 10 From date
C PARM TODAT 10 To date
C PARM '*JOB ' FRMFMT 7 From format
C PARM '*YYMD ' TOFMT 7 To format
The following is an example of TAADATFG (10 byte date fields)
C CALL 'TAADATFG' CVTDAT tool
C PARM DATE FRMDAT 10 From date
C PARM TODAT 10 To date
C PARM '*JOB ' FRMFMT 7 From format
C PARM '*YYMD ' TOFMT 7 To format
C PARM '*JOB ' TOSEP 7 To sep char
If you are writing in RPGLE, there is normally no reason for the use
of either subprogram because RPGLE supports the conversion of one
date type to another. However, you must pre-define the format types
that you are dealing with (that is you must know that you will
convert a *MDY to *YYMD). If you cannot pre-define the date types,
you can use RPGLE, but you will have to define all of the possible
types.
While these subprograms provide a reasonable performance solution for
a small number of dates to be converted, it is not reasonable to use
for a large file where every record needs to be converted. If you
have a large number of dates to be converted, it is best handled by
coding a routine in your HLL.
TAADATFF as a subroutine to convert *CYMD format to *JOB format
---------------------------------------------------------------
The following is RPG III code designed to be copied in as a standard
subroutine and interface for converting *CYMD format to *JOB format
See the notes describing the support and error handling.
The xxx field is your input date in *CYMD format. The yyy field is
the return date in *JOB format.
The *CYMD format can contain any value for century. It could be an
invalid character. The century is forced to be within the range that
the system CVTDAT command can convert. If you do not have a century,
use a function like:
C '0' CAT xxx ZZFDAT P *CYMD fmt
instead of the MOVEL shown.
The ZZDTNM field allows you to add unique text to the error message
if a conversion error occurs so you can determine which date failed.
The typical use would be to place the name of the field you are
converting into ZZDTNM which is defined as a *CHAR LEN(10) field.
ZZDTNM is reset to blanks by the subroutine.
I* Qualified program name for CVTDAT
I 'TAATOOL/TAADATFF ' C ZZDATC
.
C MOVELxxx ZZFDAT P *CYMD fmt
C MOVEL' 'ZZDTNM Name of fld
C EXSR ZZCVTD Convert date
C MOVE ZZDAT6 yyy 60 Job date fmt
.
C****************************************************************
C* *
C* ZZCVTD Convert date - From *CYMD to *JOB *
C* *
C****************************************************************
C ZZCVTD BEGSR Convert date
C CALL ZZDATC Date convert
C PARM ZZFDAT 7 From date
C PARM ZZDAT6 6 To date
C PARM ZZDTNM 10 Date name
C MOVE *BLANKS ZZDTNM Reset
C ENDSR Convert date
C****************************************************************
The following is RPG IV code for the same function.
D* Qualified program name for CVTDAT
D ZZDATC C CONST('TAATOOL/TAADATFF ')
.
C MOVEL(P) xxx ZZFDAT
C MOVEL ' ' ZZDTNM
C EXSR ZZCVTD
C MOVE ZZDAT6 yyy 6 0
.
C****************************************************************
C* *
C* ZZCVTD Convert date - From *CYMD to *JOB *
C* *
C****************************************************************
C ZZCVTD BEGSR
C CALL ZZDATC
C PARM ZZFDAT 10
C PARM ZZDAT6 6
C PARM ZZDTNM 10
C MOVE *BLANKS ZZDTNM
C ENDSR
Support and Error Handling with TAADATFF
----------------------------------------
If the current *JOB date format is *JUL, it is automatically changed
to *YMD.
The routine is designed not to fail. The system CVTDAT command is
used to convert dates. CVTDAT has restrictions on the range of dates
that can be converted. The CVTDAT range of dates is ignored. The
TAADATFF program determines the century (0 or 1) by checking the year
for LT 40. Since only a 6 digit date is returned, this allows
TAADATFF to support dates outside of the CVTDAT range.
If any escape messages are sent by CVTDAT (such as an attempted
conversion from month 13), the TAADATFF program monitors and returns
zeros in the ZZDAT6 field. A diagnostic message is sent if an error
occurs.
TAADATFH as a subroutine to convert *CYMD format to *JOB format
---------------------------------------------------------------
The following is RPG III code designed to be copied in as a standard
subroutine and interface for converting *CYMD format to *JOB format
including the job separator character for the date.
The xxx field is your input date in *CYMD format. The yyy field is
the return date in *JOB format.
The *CYMD format can contain any value for century. It could be an
invalid character. The century is forced to be within the range that
the system CVTDAT command can convert. If you do not have a century,
use a function like:
C '0' CAT xxx ZZFDAT P *CYMD fmt
instead of the MOVEL shown.
The ZZDTNM field allows you to add unique text to the error message
if a conversion error occurs so you can determine which date failed.
The typical use would be to place the name of the field you are
converting into ZZDTNM which is defined as a *CHAR LEN(10) field.
ZZDTNM is reset to blanks by the subroutine.
I* Qualified program name for CVTDAT
I 'TAATOOL/TAADATFH ' C ZZDATC
.
C MOVELxxx ZZFDAT P *CYMD fmt
C MOVEL' 'ZZDTNM Name of fld
C EXSR ZZCVTD Convert date
C MOVE ZZDAT8 yyy 8 Job date fmt
.
C****************************************************************
C* *
C* ZZCVTD Convert date - From *CYMD to *JOB *
C* *
C****************************************************************
C ZZCVTD BEGSR Convert date
C CALL ZZDATC Date convert
C PARM ZZFDAT 7 From date
C PARM ZZDAT8 8 To date
C PARM ZZDTNM 10 Date name
C MOVE *BLANKS ZZDTNM Reset
C ENDSR Convert date
C****************************************************************
Parameters for TAADATFC
-----------------------
FROM The from date. This is a 6 byte character field.
TO The to date to be returned. This is a 6 byte
character variable.
FROMFMT The format of the from date. This is a 4 position
field with the same values as on CVTDAT such as
*SYSVAL, *JOB, *MDY, *DMY, *YMD, and *JUL.
TOFMT The format of the to date. This is a 4 byte
character variable with the same values as FROMFMT.
Parameters for TAADATFE
-----------------------
FROM The from date. This is a 10 byte character field.
TO The to date to be returned. This is a 10 byte
character variable.
FROMFMT The format of the from date. This is a 7 position
field with the same values as on CVTDAT such as
*SYSVAL, *JOB, *MDY, *MDYY, *JUL, *ISO, etc.
TOFMT The format of the to date. This is a 4 byte
character variable with the same values as FROMFMT.
Parameters for TAADATFF
-----------------------
FROM The from date. This is a 7 byte field in the format
CYMD.
TO The to date to be returned. This is a 6 byte
character variable.
DATNAM The name of the date field being converted. The
purpose of this field is to assist in error
conditions. The error text will include the name of
the field.
Parameters for TAADATFG
-----------------------
FROM The from date. This is a 10 byte character field.
TO The to date to be returned. This is a 10 byte
character variable.
FROMFMT The format of the from date. This is a 7 position
field with the same values as on CVTDAT such as
*SYSVAL, *JOB, *MDY, *MDYY, *JUL, *ISO, etc.
TOFMT The format of the to date. This is a 4 byte
character variable with the same values as FROMFMT.
TOSEP The type of separator to be used in the To date.
This is a 7 byte character field with the same
values as on the CVTDAT command (i.e. *NONE, *JOB,
*SYSVAL, *BLANK, '/', '-', '.', and ','.
Parameters for TAADATFH
-----------------------
FROM The from date. This is a 7 byte field in the format
CYMD.
TO The to date to be returned. This is a 8 byte
character variable with the inserted job date
separator.
DATNAM The name of the date field being converted. The
purpose of this field is to assist in error
conditions. The error text will include the name of
the field.
Prerequisites
-------------
The following TAA Tools must be on your system:
SNDESCMSG Send escape message
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ----- --------- ---------- -----------
TAADATFC *PGM CLP TAADATFC QATTCL
TAADATFE *PGM CLP TAADATFE QATTCL
TAADATFF *PGM CLP TAADATFF QATTCL
TAADATFG *PGM CLP TAADATFG QATTCL
TAADATFH *PGM CLP TAADATFH QATTCL
|