TAA Tools
UPDFLD          UPDATE FIELD                           TAADBHK

The Update Field command allows  a single field in a data  base file to
be changed  to a specified  value.  Either  all records are  changed or
you may specify a simple selection criteria.

A typical command would be:

             UPDFLD        FILE(xxx) +
                             SELFLD(FLDB) SELOP(*EQ) SELVAL(XYZ)
                             UPDFLD(FLDC) UPDVAL(ABC)

This  would select any records  where FLDB is equal  to XYZ.  The field
FLDC would be updated to a value of ABC.

An audit  entry  is sent  to  the QAUDJRN  if it  exists.   If  not,  a
message is  sent to QSYSOPR to  provide an audit trail  that UPDFLD was
used.

You should consider the command is to be specified as:

      - If the selection criteria is true
      - Update the specified field

The  SELOP parameter  supports the normal  functions of  *EQ, *GE, *GT,
*LE, *LT, and *NE.  *CT (contains) is also supported.

You can also use the command without selection such as:

             UPDFLD        FILE(FLDZ) UPDFLD(yyy) UPDVAL(ABC)

All records in the  first member of the file  would be changed for  the
field FLDZ to a new value of ABC.

You  must  have *ALL  authority  to  the  file  to use  UPDFLD.    This
normally  restricts  the  command to  a  user  who  either has  *ALLOBJ
special authority or owns the file.

UPDFLD can be helpful when  adding a new field to  a file and you  want
to initialize it for all  records to a specific value or  when you must
perform a simple maintenance function.

The file is always processed in arrival sequence.

Two special  values *BLANKS and *ZEROS may be  specified for either the
SELVAL  or UPDVAL parameter.   This allows a field to  be set to blanks
or zeros or a  records may be selected  for update if a  field contains
a value  of blanks  or zeros.   For example,  specifying UPDVAL(*ZEROS)
may be  helpful to reset 'year to date'  fields at the beginning of the
year.

If a  character  or variable  length  field  is described,  the  UPDVAL
value is moved  from the left into  the field and the  remainder of the
field  is blanked  out.   If a  variable length  field is  updated, the
actual length of the data  is used to update  the leading two bytes  of
the internal  field.   A maximum size  character field  of 50  bytes is
supported.

If  a  decimal  field is  described  (packed,  zoned,  or binary),  the
UPDVAL  value must be all  digits and the same  number must exist as is
defined for the field.  For  example, if the field is declared  as *DEC
LEN(5 0),  5 digits must be  entered.  To  set the field to  a value of
30, you would specify:

          UPDVAL(00030)

A  similar convention is used  with the SELVAL parameter.   To select a
field that  is declared  as *DEC  LEN(5 2)  for a  value  of 50.00  you
would specify:

          SELVAL(05000)

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

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

                 A physical file or logical  file with a single  format
                 may be specified.

   SELFLD        The field  name in the  file to select  on.  Only  the
                 types  character, variable  length, packed,  zoned, or
                 binary  are  supported.    A  character  field  cannot
                 exceed 50 bytes in length.

   SELOP         The operation to be  used for selection.   The default
                 is *EQ.   The other  values that may be  specified are
                 *GE  *GT  *LE *LT,  *NE or  *CT  (contains).   The *CT
                 function  scans  the  field  in  the  record  for  the
                 select  value.    *CT  is   limited  to  character  or
                 variable  length  fields.   The length  of  the select
                 value as determined by the  last non-blank is used  to
                 limit the scan.

   SELVAL        The value of  the selection field to cause  the record
                 to be updated.

                 The  special value *BLANKS  may be  entered (beginning
                 in position 1) to select on a blank value.

                 If  the  selection  field  is  declared  as  a decimal
                 type, the  value  must match  in  terms of  number  of
                 digits  and only  digits  may be  entered.   An  error
                 message  will  occur  if the  exact  number  of digits
                 entered does  not  agree with  the  field  definition.
                 The  value is  tested appropriately  depending on  the
                 type of  packed, zoned, or binary.   The special value
                 *ZEROS may  be entered  (beginning in  position 1)  to
                 test for zeros in the selection field.

   UPDFLD        The field name  in the file  to be updated.   Only the
                 types  character, variable  length, packed,  zoned, or
                 binary  are  supported.    A  character  field  cannot
                 exceed 50 bytes in length.

   UPDVAL        The  value  to be  assigned  to  the  field.    For  a
                 character  field, the  data  is  moved beginning  with
                 the  leftmost byte of  the value to  the leftmost byte
                 of the field.   Any  remaining characters are  blanked
                 out.

                 The special  value *BLANKS  may be  entered (beginning
                 in position 1) to blank out the entire field.

                 For  a decimal  field, the value  must match  in terms
                 of number of  digits and only  digits may be  entered.
                 An error  message will  occur if  the exact number  of
                 digits   entered  does  not   agree  with   the  field
                 definition.     The   value  is   moved  appropriately
                 depending on  the type  of packed,  zoned, or  binary.
                 The  special value  *ZEROS may  be entered  (beginning
                 in position 1) to zero out the field.

   MBR           The  member of  the file to  be updated.   The default
                 is *FIRST.

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

Several restrictions are stated throughout such as:

  **   You must have *ALL authority to the file.

  **   A maximum of a 50 byte field character field may be named.

  **   Multi-format logical files are not supported.

  **   If a  decimal field  is to  be selected  on to  be updated,  the
       exact number of digits must be entered.

  **   A file which allows null values is not supported.

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

The following TAA Tools must be on your system:

     EDTVAR          Edit variable
     RTVFLDA         Retrieve field attributes
     HLRMVMSG        HLL Remove message
     RTVVALA         Retrieve value attributes
     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
   ------        ----    ---------      ----------    ----------

   UPDFLD        *CMD                   TAADBHK       QATTCMD
   TAADBHKC      *PGM       CLP         TAADBHKC      QATTCL
   TAADBHKR      *PGM       RPG         TAADBHKR      QATTRPG
					

Added to TAA Productivity tools April 1, 1995


Home Page Up to Top