The Copy and Reformat command provides better reformatting capability
than the system CPYF command which supports only *MAP and *DROP. In
addition to *MAP and *DROP functions, CPYRFMT allows renaming of a
field. The To file must exist.
Typical situations
------------------
Example 1
---------
Assume you have a file with a field name of AMT and you want to
rename the field to AMTOWE and increase the length. All other fields
should remain the same. You would change the DDS of the new To file
for the AMTOWE field and create the file in a separate library. Then
issue the following:
CPYRFMT FROMFILE(xxx) TOFILE(yyy)
FLDLST((AMT AMTOWE))
The AMT field would be mapped to the AMTOWE field.
Example 2
---------
Assume you need to add several new fields to a master file, change
the order of the existing fields and change the definition of 3 zoned
fields (ZON1, ZON2, ZON3) to packed fields (PCK1, PCK2, PCK3). The
ZON2 field was defined as 5 digits with 2 decimals and should be
increased to 9 digits with 3 decimals.
You would change the DDS of the ZONn fields, increase the digits and
decimal positions for the ZON2 field, add the new fields and reorder
the fields as required.
The command to issue would be:
CPYRFMT FROMFILE(xxx) TOFILE(yyy) ALWDFTVAL(*YES)
FLDLST((ZON1 PCK1)(ZON2 PCK2)(ZON3 PCK3)
If any fields exist in the To file that do not have a corresponding
field in the From file or are described in the FLDLST parameter, you
must specify ALWDFTVAL(*YES).
The following data types for the To file are supported as follows:
A = Char The From field must be A (Character), W (Var
length), P (Packed), S (Zoned), L (Date), T (Time),
or Z (Time Stamp).
If mapping from L, T, or Z fields, minimum lengths
are required in the To field.
Any additional length is padded on the right with
blanks. Truncation occurs without error.
W = Var Len The From field must be A (Character) or W (Var
length).
P = Packed The From field must be P (Packed) or S (Zoned). Any
additional length is padded on the left with zeros.
Truncation occurs without error.
P = Packed The From field must be P (Packed) or S (Zoned). Any
additional length is padded on the left with zeros.
Truncation occurs without error.
L = Date. The From field may only be an L type field. The
DATFMT value of the From field must match the DATFMT
value of the To field.
T = Time. The From field may only be an T type field.
Z = TimStm The From field may only be an Z type field.
CPYF versus CPYRFMT
-------------------
The major functions supported by both CPYF and CPYRFMT are:
** Different format names are allowed.
** Rearranging of the field names.
** Fields may be dropped in the new format.
** Fields may be changed in field length or decimal positions and
the decimal types may be changed (eg packed to zoned).
** A change from a decimal field to a character field.
CPYF does not:
** Allow a change of field name.
** Describe the actual length of the data when copying from
character to variable length (the full length of the field is
used).
CPYRFMT escape messages you can monitor for
-------------------------------------------
None. Escape messages from based on functions will be re-sent.
CPYRFMT Command parameters *CMD
--------------------------
FROMFILE The qualified name of the From file to be read from.
The library value defaults to *LIBL. A specific
library or *CURLIB may also be used.
TOFILE The qualified name of the To file to write records
to. The library value defaults to *LIBL. A
specific library or *CURLIB may also be used.
FROMMBR The member of the From file. *FIRST is the default.
A specific member or *LAST may be entered.
TOMBR The member of the To file. *FIRST is the default.
A specific member or *LAST may be entered.
MBROPT The member option.
*ADD is the default to add records to the existing
member.
*REPLACE may be specified to replace records in the
existing member.
ALWDFTVAL A *YES/*NO value for whether fields in the To file
may exist that are not defined in the From file or
in the FLDLST parameter.
*NO is the default. If fields in the To file are
not defined to allow a copy, an escape message is
sent.
*YES may be specified to allow fields that are not
defined to be output as blanks or zeros. L (Date)
fields are initialized to Jan 1, 1900 in the date
format specified for the field. T (Time) fields are
initialized to 00.00.00. Z (Timestamp) fields are
initialized to 1900-01-01-00.00.000000.
FLDLST The field list parameter allows a From and To field
to be described when a field is being renamed in the
To file.
For example, if the field is ABC in the From file,
it may be copied to the DEF field in the To file by
making the entry:
FLDLST((ABC DEF))
Up to 50 entries may be made. The To field name may
only be used once in the To entry. The From field
name may be used multiple times in the From entry.
For example, if FLD1 exists in the From file, the
data may be replicated to FLD8 and FLD9 in the To
file with:
FLDLST((FLD1 FLD8)(FLD1 FLD9))
If FLD1 also exists in the To file, it will have the
same data. If FLD8 or FLD9 also exists in the From
file, the FLDLST parameter takes precedence and the
fields would be filled with the FLD1 data.
Restrictions
------------
Both files must be externally described.
Both files may have a maximum length of 9999 bytes.
Not all data types are supported.
Prerequisites
-------------
The following TAA Tools must be on your system:
CHKDBFMBR Check data base file member
EDTVAR Edit variable
EXTLST Extract list
RTVFLDARR Retrieve field array
HLRMVMSG HLL Remove message
LOOKUP Lookup
RSNLSTMSG Resend last message
RTVDBFA Retrieve data base file attributes
RTVFLDA Retrieve field attributes
SNDCOMPMSG Send completion message
SNDESCINF Send escape information
SNDESCMSG Send escape message
SNDSTSCNT Send status count
Implementation
--------------
None, the tool is ready to use.
Objects used by the tool
------------------------
Object Type Attribute Src member Src file
------ ---- --------- ---------- ----------
CPYRFMT *CMD TAADBMU QATTCMD
TAADBMUC *PGM CLP TAADBMUC QATTCL
TAADBMUR *PGM RPG TAADBMUR QATTRPG
|