To copy a physical or logical file (the from-file) on AS/400 into another physical file (the to-file), which does not yet exist, you can use the CPYF command, as in the following 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 usually 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 Creating the to-file (CRTFILE parameter) for details.
See Copying files: overview to learn about the basic functions relating to the AS/400 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 systems:
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.