Copy physical or logical files

To copy a physical or logical file (the from-file) on iSeries™ into another physical file (the to-file), which does not yet exist, you can use the CPYF command.

Below is an example:
    CPYF   FROMFILE(PERSONNEL/PAYROLL) 
       TOFILE(TESTPAY/PAYROLL)  MBROPT(*ADD) 
       CRTFILE(*YES)  ERRLVL(10) 

Full-service copy support

A variety of copy commands that are modified by numerous parameters gives you a great deal of flexibility in the way you copy your data. For instance, you typically can copy your data into existing files (or to-files). As shown in the example above, you can use the CRTFILE parameter on the CPYF or CPYFRMQRYF commands to create the to-file during the copy operation. See Create the to-file (CRTFILE parameter) for details.

See Copy files: overview to learn about the basic functions relating to the iSeries copy commands.

Copy only the information you need

The copy function lets you specify selected records and members of your files:

Copy across different formats and servers

Make the copy function work for your particular needs

You can accomplish a wide variety of tasks with careful use of the options that are available to you through the copy function.
Related concepts
Copy files: overview
Create the to-file (CRTFILE parameter)
Select members to copy
Add, replace, and update records (MBROPT parameter)
Select the records to copy
Related information
CPYF command
CPYFRMQRYF command