Copying files: Commands

 

You can copy records to and from files with commands discussed in this topic. To copy records to and from files, use the following commands:

CPYF

Copy File (CPYF) command copies all or part of a file from the database or external device to the database or external device.

CPYFRMTAP

Copy from Tape (CPYFRMTAP) command copies from a tape file to a database or device file. The from-file must be a tape file, but the to-file can be a physical file, diskette file, tape file, or program-described printer file. You can obtain a formatted listing of the records by using QSYSPRT.

CPYTOTAP

Copy to Tape (CPYTOTAP) command copies from a database or device file to a tape file. The to-file must be a tape file, but the from-file can be a physical, logical, diskette, tape, or inline data file.

CPYSRCF

Copy Source File (CPYSRCF) command copies a database source file to a source physical file and converts the data in the from-file to the to-file CCSID. You can create a formatted listing by using QSYSPRT (the file is changed for source records and is different from other copy command file formats). Record data is copied from the from-file to the to-file, disregarding differences in record formats (similar to the FMTOPT(*NOCHK) parameter option on the CPYF command, except for the CCSIDs.)

CPYFRMQRYF

Copy from Query File (CPYFRMQRYF) command copies an open query file to a database or device file.

The system does not reclaim DDM conversations for a job when a copy command produces an error.

If you specify a DDM file and a local file on the CPYF or CPYSRCF commands, the system does not verify that the remote and local files are not the same on the source system. If you specify one DDM file, you can potentially copy to and from the same file.

For information about how to copy DBCS-open fields to graphic fields (including the option of removing trailing single-byte blanks for the DBCS-open field first), see DBCS-graphic fields using FMTOPT(*MAP) or FMTOPT(*NOCHK).

Throughout this topic, unless the text specifies a specific command, the term copy commands refers to all the commands just described.

The device and database files where you can perform copy operations are shown in Table 1.


Table 1. Copy operations
From-files To-files
DDM DDM
Diskette1 Diskette1
Logical Physical2
Open query3 Printer
Physical *PRINT4
Inline data5 Tape
Tape  
Notes:

1

If the from-file and the to-file are both diskette files, the to-file must be spooled.

2

If the to-file does not exist before the copy operation, the copy operation will create a physical file as the to-file if you specified:

3

Open query files can only be copied by using the CPYFRMQRYF command. CPYFRMQRYF is not allowed for open query files that use DDM files.

4

If TOFILE(*PRINT) is specified, the from-file records are copied to the IBM-supplied printer device file QSYSPRT and formatted according to the OUTFMT parameter.

5

An inline data file (which is handled like a device file) is included as part of a batch job when the job is read by a reader program.

While copying records, some of the copy commands can perform the following functions:

 

Parent topic:

Copying files: Overview