File Management - IBM

File Management - IBM File Management - IBM

as400bks.rochester.ibm.com
from as400bks.rochester.ibm.com More from this publisher
30.06.2013 Views

When you specify PRINT(*EXCLD), the records print in the from-file format. All character data is in the CCSID specified in the from-file field. For TOFILE(*PRINT) and PRINT(*COPIED) listings, and when the to-file is a print file, character data is in the CCSID specified in the to-file fields. Example: In this example, all records that are not copied (or excluded records) are printed: CPYF FROMFILE(DKTIN) TOFILE(LIB1/PF) + MBROPT(*ADD) INCCHAR(*RCD 80 *EQ X) + PRINT(*EXCLD) The records print in character format. Creating an unformatted print listing If you want an unformatted print listing or if the from-file records should be formatted using first-character forms control (CTLCHAR(*FCFC), you must specify a program-described printer device file name. This file name can be QSYSPRT or user-defined (instead of *PRINT). To format the from-file records using first-character forms control, specify CTLCHAR(*FCFC) on the Create Printer File (CRTPRTF), Change Printer File (CHGPRTF), or Override Printer File (OVRPRTF) command. For copy commands where TOFILE(*PRINT) is specified with a PRINT parameter value of *COPIED, *EXCLD, or *ERROR (or any combination), the following limits apply: v The QSYSPRT file must be spooled [SPOOL(*YES)] v You must specify the QSYSPRT in the device file or on the OVRPRTF command, because separate print files open for each file requested. All records are copied to a single spooled file, and the data for each member or label identifier copied begins on a new print page. Copying between different database record formats (FMTOPT parameter) 106 File Management V4R5 (CPYF and CPYFRMQRYF commands) When you copy from a database file to a database file, you must use the FMTOPT parameter if the record formats are not identical or if the files are different types (source or data). If either file is a device file or inline data file, the FMTOPT parameter does not apply. The records are truncated or padded with blanks or zeros when record lengths are different. A message is sent if the records are truncated. For database files, when either FMTOPT(*CVTSRC) or FMTOPT(*NOCHK) is specified and the record data copied from any from-file record is not long enough to fill a to-file record, the extra bytes in the to-file record are set to a default value. If a default value other than *NULL is specified in the DDS (DFT keyword) for a field, that field is initialized to the specified default; otherwise, all numeric fields are initialized to zeros, all character fields are initialized to blanks, all date, time,

and timestamp fields are initialized to the current system date and time. If *NULL is specified on the DFT keyword, only the default buffer value is used. A *NULL default is ignored. If the from-file or to-file is a device file or an inline data file, copy automatically adds or deletes the source sequence number and date fields for each record copied. If one file is a data file and the other a source file, you must specify FMTOPT(*CVTSRC) to perform the copy. The sequence number and date fields are added or deleted as appropriate and the data part of each record is copied without regard to the other field definitions in the file record formats. The SRCSEQ parameter can be used to control how the sequence numbers are created, provided SRCOPT(*SEQNBR) is also specified. For database-to-database copies, you can reconcile any differences in record formats by specifying: v *DROP to drop those fields in the from-file record format for which there are no fields of the same name in the to-file record format. v *MAP to convert fields in the from-file to the attributes of like-named fields in the to-file and to fill extra fields in the to-file, that are not in the from-file, with their default values. The default values are: – The parameter value (including *NULL) for the DFT keyword, if specified for the field – Blanks (for character fields without the DFT keyword) – Zeros (for numeric fields without the DFT keyword) – Current date, time, or timestamp for those type fields without the DFT keyword *MAP is required if fields with the same name are in different positions in the file record formats, even though these fields have the same attributes. v *DROP and *MAP to drop fields in the from-file not named in the to-file and to convert remaining fields through mapping rules to fit the to-file fields that have different attributes or positions. v *NOCHK to disregard the differences. Data is copied left to right directly from one file to the other. Null values are ignored. The copied records are either truncated or padded with default buffer values. Because no checking is done, fields in the to-file may contain data that is not valid for the field as defined. Dropping and mapping fields are based on a comparison of field names. Unless all the fields in the from-file have the same name in the to-file, you must specify *DROP. If the names are the same, but the attributes or position in the record is different, you must specify *MAP. Dropped fields are not copied. There must be at least one like-named field in both record formats to do mapping. When *MAP is specified, fields in the to-file record format that do not exist in the from-file record format are filled with their default values, as described earlier in this section. For fields that have the same name and attributes, the field in the from-file record format is mapped to the field with the same name in the to-file record format, even if their positions in the formats are different. For example, the field CUSNO is the first field in the record format ORDHD, but it is the second field in record format ORDHD1. When the CUSNO field is copied with *MAP, it is mapped to the second field of ORDHD1. Chapter 4. Copying files 107

and timestamp fields are initialized to the current system date and time. If *NULL<br />

is specified on the DFT keyword, only the default buffer value is used. A *NULL<br />

default is ignored.<br />

If the from-file or to-file is a device file or an inline data file, copy automatically<br />

adds or deletes the source sequence number and date fields for each record copied.<br />

If one file is a data file and the other a source file, you must specify<br />

FMTOPT(*CVTSRC) to perform the copy. The sequence number and date fields are<br />

added or deleted as appropriate and the data part of each record is copied without<br />

regard to the other field definitions in the file record formats. The SRCSEQ<br />

parameter can be used to control how the sequence numbers are created, provided<br />

SRCOPT(*SEQNBR) is also specified.<br />

For database-to-database copies, you can reconcile any differences in record<br />

formats by specifying:<br />

v *DROP to drop those fields in the from-file record format for which there are no<br />

fields of the same name in the to-file record format.<br />

v *MAP to convert fields in the from-file to the attributes of like-named fields in<br />

the to-file and to fill extra fields in the to-file, that are not in the from-file, with<br />

their default values. The default values are:<br />

– The parameter value (including *NULL) for the DFT keyword, if specified for<br />

the field<br />

– Blanks (for character fields without the DFT keyword)<br />

– Zeros (for numeric fields without the DFT keyword)<br />

– Current date, time, or timestamp for those type fields without the DFT<br />

keyword<br />

*MAP is required if fields with the same name are in different positions in the file<br />

record formats, even though these fields have the same attributes.<br />

v *DROP and *MAP to drop fields in the from-file not named in the to-file and to<br />

convert remaining fields through mapping rules to fit the to-file fields that have<br />

different attributes or positions.<br />

v *NOCHK to disregard the differences. Data is copied left to right directly from<br />

one file to the other. Null values are ignored. The copied records are either<br />

truncated or padded with default buffer values. Because no checking is done,<br />

fields in the to-file may contain data that is not valid for the field as defined.<br />

Dropping and mapping fields are based on a comparison of field names. Unless all<br />

the fields in the from-file have the same name in the to-file, you must specify<br />

*DROP. If the names are the same, but the attributes or position in the record is<br />

different, you must specify *MAP. Dropped fields are not copied. There must be at<br />

least one like-named field in both record formats to do mapping.<br />

When *MAP is specified, fields in the to-file record format that do not exist in the<br />

from-file record format are filled with their default values, as described earlier in<br />

this section. For fields that have the same name and attributes, the field in the<br />

from-file record format is mapped to the field with the same name in the to-file<br />

record format, even if their positions in the formats are different.<br />

For example, the field CUSNO is the first field in the record format ORDHD, but it<br />

is the second field in record format ORDHD1. When the CUSNO field is copied<br />

with *MAP, it is mapped to the second field of ORDHD1.<br />

Chapter 4. Copying files 107

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!