TAA Tools

The Delete  Data Base  Date command  deletes (or checks)  records in  a
data base file  based on a comparison of a  field value and a specified
date  and operator.   Different date  formats are  valid for character,
zoned, packed, date,  or time  stamp fields.   DLTDBFDAT can assist  in
cleaning up files.

Another  solution is  to use  the CPYDBFDAT  tool which  allows purging
old  records  by copying  good  records to  a temporary  file  and then
copying back.

The default of  DLTDBFDAT is  ACTION(*CHECK) which  produces a  listing
of the records  that would be deleted  from the first 2,000  records in
the  file.  The  intent of the  2,000 limit (it  can be  changed) is to
allow you to  confirm the results  as to  what will be  deleted.   Once
you  are  satisfied  with your  specifications,  the  typical  solution
would  be to  specify  ACTION(*DELETE)  and OUTPUT(*NONE).    This will
delete the requested records and no listing is output.

You must have all rights to the file to use DLTDBFDAT.

A  typical command to check the records  that would be deleted based on
field DATE1 if the  value of the field in  *MDY format is prior  to Jan
1, 2002 would be:

                          CMPDATE(010102) IDFLD(NAME)

Because  the default is  ACTION(*CHECK), no  records would  be deleted.
Only  the records that would be deleted  will appear in the listing and
only the first 2,000 records would be processed.

The DATE1 field would be checked  for a valid length and type based  on
the  *MDY value  for DATFMT.   For  example, if  it is  a character  or
zoned  field, it must  have a  length of 6  bytes.   If it is  a packed
field, it must  have 6  digits.   If DATFMT(*USA)  had been  specified,
the DATE1 field must be an L field type.

The default is  to compare the  date specified against the  field value
for a  *LT condition.   This would mean  that all records  containing a
value prior to Jan 1, 2002 would be considered for deletion.

A  listing would be produced  with one line for  each record that would
be deleted if  ACTION(*DELETE) had been specified.   Both the value  in
the  record  and  the  CYMD  value  of the  converted  date  (used  for
comparison)  would be  shown.   The first  15 bytes  of the  field NAME
would be listed  on the same line  to help identify  the records to  be

The  default is  to  consider any  blank date  values  as errors  which
would cause the record to be flagged.

Any records with invalid dates would also be flagged.

DLTDBFDAT escape messages you can monitor for

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

DLTDBFDAT Command parameters                         *CMD

   FILE          The  qualified name of the  file containing the dates.
                 The library  value  defaults  to *LIBL.    A  specific
                 library or *CURLIB may also be used.

   DATFLD        The name  of the field  to be checked.   It must  be a
                 field  in  the  named  file  and  must  be  a  type  A
                 (Character),  S (Zoned),  P (Packed),  L (Date),  or Z
                 (Timestamp).  It  must have a length  that corresponds
                 to the  DATFMT value.   For example,  if DATFMT(*YYMD)
                 is  specified and the field is  A = Character, it must
                 have a length of 8 bytes.

   DATFMT        The date  format of  the field  to be  compared.   The
                 value must be  *MDY, *DMY, *YMD, *MDYY,  *DMYY, *YYMD,
                 *CYMD, *ISO, *USA, *EUR, *JIS, or *TIMSTM.

   CMPDATE       The  date to compare  to determine if  the record will
                 be deleted.    The  date  should  be  entered  in  job
                 format regardless  of the  format of  the field to  be

                 All 2  digit year dates must  be in a range  of Jan 1,
                 1940  to Dec  31, 2039.   All 4 digit  year dates must
                 be in a range of Aug 24, 1928 to May 9, 2071.

   SELOP         The select operation  to use when  comparing.  *LT  is
                 the  default.   *EQ,  *NE,  *LE, *GT,  or  *GE may  be

   CENFLD        The  name  of  the field  which  contains  the century
                 value as an independent field.

                 *NONE  is  the   default  meaning   the  DATFLD   name
                 contains the entire date.

                 A field  name may be  entered to describe  the century
                 field  to be used  in the  date comparison.   This may
                 only be used  with a  DATFMT value of  *MDY, *DMY,  or
                 *YMD.   The field must  be a type  A = Character,  S =
                 Zoned, or  P = Packed and be one  byte (or one digit).

                 A   separate  century  field   is  typical  of  system
                 outfiles  such  as  the  QADSPOBJ  format  of  DSPOBJD
                 which  uses ODCCEN  (one byte  century) and  ODCDAT (6
                 byte  date in  *MDY  format) for  the date  the object
                 was created.

   SEPARATORS    A *YES/*NO  value for  whether the  data  in the  data
                 base has separator characters such as a /.

                 *NO is  the default.   *NO must  be specified  for the
                 decimal  type fields P  (Packed) or  S (Zoned) fields.
                 *NO must be  specified for L  (Date) or Z  (Timestamp)
                 as they have an implied separator.

                 *YES may be  specified if the  field in the  data base
                 has  separators,  but  must  use the  following  rules
                 (the  actual  separator  character  is  ignored,  / is
                 used in the examples):

                 The *CYMD type must be 9 bytes and appear as:


                 The *MDY,  *DMY, and *YMD  types must  be 8 bytes  and
                 appear as:


                 The *MDYY or  *DMYY types must be 10  bytes and appear


                 The *YYMD type must be 10 bytes and appear as:


   IDFLD         A  list of up to  3 fields which  will be printed with
                 each record where  the date  value is found.   If  you
                 have a unique  key to the file, the  unique key fields
                 should  be  specified  to  help  identify the  record.
                 The ID fields  must be of  a type A =  Character, S  =
                 Zoned, or P = Packed.

                 The default is  *DFT in which  case if the  command is
                 entered interactively,  a subfile is  displayed of all
                 the  (A, Z, and P) fields  in the file and a selection
                 may be made.   A typical solution  is to enter an  'X'
                 to  select the  fields needed  to identify  the record
                 (up  to  3 fields  may be  selected).   When  Enter is
                 pressed, the display  is refreshed  with the  selected
                 fields at the  top.  When Enter is  pressed again with
                 no changes, the command begins operation.

                 Only  the first 15  positions of each  ID field print.

                 An IDFLD  may not  be  specified if  OUTPUT(*NONE)  is

                 If DLTDBFDAT  is entered  in batch,  a list of  fields
                 or *DFT may be used.

   MBR           The member  name of the file.   *FIRST is the default.
                 *LAST or a specific member name may be specified.

   ACTION        The action to be taken.

                 *CHECK  is the default.   No records would be deleted.
                 OUTPUT(*NONE) may not be  specified.  A listing  would
                 be   output   to   allow   a   review   before   using

                 *DELETE  may be  specified  to cause  records matching
                 the comparison criteria  to be  deleted.   Any of  the
                 OUTPUT options may be used.

   BLANKDATES    An  option  to determine  how  a  blank or  zero  date
                 value should be considered.

                 *ERROR  is the  default meaning  any blank  values for
                 character fields or  zero values for  zoned or  packed
                 fields  would be  considered  an  error and  would  be

                 For  L  (Time)  or  Z  (Timestamp fields)  a  date  of
                 1900-01-01 is considered a blank value.

                      To   delete  records   containing  blank  values,
                      consider a tool such as DLTDBFRCD.

                 *IGNORE  may  be specified  to  ignore  these  records
                 (they would not be deleted).

   NBRRCDS       The number of records to be processed.

                 *DFT is the default.

                      If  ACTION(*CHECK)  is  specified,  2000  records
                      will  be  processed.   This  prevents  creating a
                      large  listing   for   records  that   could   be
                      deleted.   The intent is  to provide enough  of a
                      listing   to  ensure   your   specifications  are
                      correct before deleting any records.

                      If ACTION(*DELETE) is  specified, all records  in
                      the file would be processed.

                 *ALL may be specified to process all records.

                 A  specific  number  of  records  may  be  entered  if
                 ACTION(*CHECK) is specified.

                 If ACTION(*DELETE)  is specified, either  *DFT or *ALL
                 must be used.

   OUTPUT        How  to  output  the results.    * is  the  default to
                 display the  spooled file  if the  command is  entered
                 interactively.   The spooled file is  deleted after it
                 is displayed.

                 If  the  command  is entered  in  batch  or  *PRINT is
                 specified, the spooled  file is  output and  retained.

                 *NONE  may be  entered  to  prevent the  listing  from
                 occurring.   *NONE  may  not be  used if  an  IDFLD is
                 described or ACTION(*CHECK) is used.


You must have all rights to the file to use DLTDBFDAT.

The file to  be processed must  not have a record  length greater  than
9999 bytes and the number of fields cannot exceed 999.

The fields  prompted  for must  have a  character length  *LE than  500
bytes or a digit length *LE 15.


The following TAA Tools must be on your system:

     CHKDBFMBR       Check data base file member
     CVTDAT2         Convert date 2
     EDTVAR          Edit variable
     EXTLST          Extract list
     EXTLST2         Extract list 2
     HLRMVMSG        HLL Remove message
     PMTFLD          Prompt field
     RSNLSTMSG       Resend last message
     RTVDBFA         Retrieve data base file attributes
     RTVFLDA         Retrieve field attributes
     RTVFLDARR       Retrieve field array
     RTVSYSVAL3      Retrieve system value 3
     SNDCOMPMSG      Send completion message
     SNDESCINF       Send escape information
     SNDESCMSG       Send escape message
     SNDSTSMSG       Send status message


None, the tool is ready to use.

Objects used by the tool

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

   DLTDBFDAT     *CMD                   TAADBMR       QATTCMD
   TAADBMRC      *PGM       CLP         TAADBMRC      QATTCL
   TAADBMRC2     *PGM       CLP         TAADBMRC2     QATTCL
   TAADBMRR      *PGM       RPG         TAADBMRR      QATTRPG

Added to TAA Productivity tools April 15, 2010

Home Page Up to Top