TAA Tools
SCNUPDDTA       SCAN AND UPDATE DATA                   TAADBIH

The Scan and Update  Data command scans a character field  for a string
and  changes the string  to a new  value.   Either character data  or a
hex  value (X'xxxx')  may be  scanned for.   The command  is useful for
cleaning up data in a file.

A typical command would be:

             SCNUPDDTA    SCNVALUE(ABC) NEWVALUE(DEF) FILE(xxx)
                            SCNFLD(NAME)

Each NAME field would  be scanned for the  value ABC.  Each  occurrence
of the ABC value would be replaced by DEF.

You  must have  *ALL  authority to  the  file to  use  SCNUPDDTA.   The
SNDAUDE  TAA Tool is  used internally to  send an entry  to the QAUDJRN
if it exists or  QSYSOPR if QAUDJRN does not  exist.  This provides  an
audit trail that SCNUPDDTA was run.

A hex  value may  also be scanned  for and replaced.   For  example, if
you  want to  find all  the instances of  X'00' in  the NAME  field and
replace it with a blank, you would specify:

             SCNUPDDTA    SCNVALUE(X'00') NEWVALUE(*BLANK) FILE(xxx)
                            SCNFLD(NAME)

The SCNFLD parameter  defaults to  *PROMPT which allows  you to  prompt
for the field names in the record format.

A spooled  file is  optional.   It will  have a line  for every  record
where  the SCNVALUE  was found and  the position  where the  string was
found.   The data  before the change is  shown.  You  may prompt for up
to 3 fields  from the record  that will assist  you in identifying  the
records that were changed.

A  Translate Table  option is  available  to assist  in converting  the
data  base data  before scanning.   This  is useful if  the data  is in
lower case.

From 1 to 5  blank characters may be scanned  for by using the  special
values *BLANK1 -  *BLANK5 for SCNVALUE.   Blank values may be  used for
NEWVALUE if *BLANK is specified.

You  may not enter  a SCNVALUE  or NEWVALUE that  is all blank  or ends
with a trailing blank.   This restriction is due  to the fact that  the
system does  not describe  the length of  the value  passed in  and the
value is trimmed of trailing blanks.

The  number of  characters entered  for SCNVALUE  and NEWVALUE  must be
the  same.  For  example, you cannot  scan for ABC  and replace it with
DEFG or DE.

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

   SCNVALUE      The value to be  scanned for.  Up  to 20 bytes may  be
                 entered.

                 If the  data in  the data base  is in lower  case, you
                 may  enter  the  specific hex  value  to  scan  for or
                 specify the TRNTBL parameter.

                 A hex  value  may be  specified by  entering  X'xxxx'.
                 If you  enter a hex  value and SPLF(*YES),  you should
                 specify   PRTHEX(*YES)  to  allow  the   value  to  be
                 printed in hex in  the spooled file.   This will  help
                 identify what type  of scan occurred.   If PRTHEX(*NO)
                 is used, the scan value may not be readable.

                 For example,  if you specify X'00' as  the scan value,
                 the  spooled file  will not identify  what you scanned
                 for unless PRTHEX(*YES) was specified.

                 An all  blank value  (X'40') or a  trailing blank  may
                 not  be  scanned  for.    The scan  value  is  trimmed
                 before  scanning which causes the  scan value (such as
                 X'C1D340') to be trimmed off.

                 The special values  *BLANK1 - *BLANK5  may be used  to
                 scan for one to 5 blanks.

   NEWVALUE      The  new value  to replace  the  string specified  for
                 the  SCNVALUE parameter.   The new  value must  be the
                 same length  as  the SCNVALUE  parameter  (you  cannot
                 scan for ABC and replace it with DEFG or DE).

                 You can insert  all blanks by using the  special value
                 *BLANK.

                 You can  enter a hex  value such as  X'51' or X'5152'.

                 You  cannot enter  a value  that ends  with a trailing
                 blank or is  all blank.   For example X'40',  X'5140',
                 and  'DE '  are not  valid.   If a  trailing  blank is
                 used,  the system  trims off  the NEWVALUE data  and a
                 shorter field would result.

   FILE          The qualified file  name of  the file  to be  scanned.
                 The  library value  defaults  to *LIBL.   *CURLIB  may
                 also be used.

                 A  physical  or logical  file (single  format)  may be
                 used.

   MBR           The member to be scanned.   The default is *FIRST  for
                 the first member of the file.

   UPDFLD        The field  to be scanned  and updated.   It must be  a
                 character  field of  500 bytes  or  less in  the named
                 file.    The  entire  field will  be  scanned  and all
                 occurrences  of the  SCNVALUE  will be  replaced  with
                 the NEWVALUE value.

                 The  default is  *PROMPT in  which case  a  subfile is
                 displayed  of  all  the  fields  in  the  file  and  a
                 selection may be made.

   TRNTBL        The Translate  Table  to  be  used.   The  default  is
                 *NONE  meaning the  SCNVALUE must  match  the data  in
                 the field to be scanned.

                 If  the data in  the field to  be scanned is  in lower
                 case, a translate  table can be  specified to  convert
                 the data before scanning.

                 *STD may be entered  to fold a-z to A-Z.   This is the
                 same  function performed  by the  QSYSTRNTBL  table in
                 QSYS.

                 A  specific translate  table and  library may  also be
                 entered.

   CHGREPORT     A *YES/*NO  value for  whether a  spooled file  should
                 be created  with the records  that were changed.   *NO
                 is the default meaning no spooled file will exist.

                 *YES  may be specified  to cause a spooled  file to be
                 created  with  one  line  for  every  value  that  was
                 replaced.

                 If *YES is specified, the IDFLD must not be *NONE.

   IDFLD         A list  of up to 3  fields which will be  printed with
                 each   record  where  the  scan   value  is  found  if
                 SPLF(*YES) is specified.   If  you have  a unique  key
                 to  the  file,   the  unique  key  fields   should  be
                 specified to help identify the record.

                 The  default  is  *NONE  which  may only  be  used  if
                 SPLF(*NO) is specified.

                 If  SPLF(*YES)  is  specified, you  must  name  one to
                 three fields  or  specify *PROMPT  to  prompt for  the
                 field.

   PRTHEX        Whether  to  print  the  scan  value  in  hex  in  the
                 spooled  listing  if  SPLF(*YES)  is  specified.   The
                 default is *NO  meaning the value  will be printed  as
                 character data.

                 If  you enter  a hex  value for  SCNVALUE, you  should
                 specify   PRTHEX(*YES)  to  allow  the   value  to  be
                 printed in  hex in  the spooled  file listing.    This
                 will help  identify what  type of  scan occurred.   If
                 PRTHEX(*NO)  is  used,  the  scan  value  may  not  be
                 readable.

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

See the previous comments.

The record length of the file cannot exceed 9999.

The number of fields cannot exceed 998.

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

The following TAA Tools must be on your system:

     CVTHEX          Convert hex
     EDTVAR          Edit variable
     EXPVAL          Expand value
     EXTLST2         Extract list 2
     FILEFDBCK       File feedback
     HLRMVMSG        HLL Remove message
     PMTFLD          Prompt field
     RTVFLDARR       Retrieve field array
     RTVSYSVAL3      Retrieve system value 3
     SNDAUDE         Send audit entry
     SNDCOMPMSG      Send completion message
     SNDESCMSG       Send escape message
     SNDSTSMSG       Send status message

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

None, the tool is ready to use.

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

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

   SCNUPDDTA     *CMD                   TAADBIH       QATTCMD
   TAADBIHC      *PGM       CLP         TAADBIHC      QATTCL
   TAADBIHR      *PGM       RPG         TAADBIHR      QATTRPG
					

Added to TAA Productivity tools June 1, 1997


Home Page Up to Top