Copying physical or logical files
To copy a physical or logical file (the from-file) on the i5/OS® operating system into another physical file (the to-file) that does not yet exist, you can use the Copy File (CPYF) command. Here 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 give 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 Creating the to-file (CRTFILE parameter) for details.
See Copying files: Overview to learn about the basic functions relating to the i5/OS copy commands.
Copying only the information you need
The copy function lets you specify selected records and members of your files:
- Adding, replacing, and updating records (MBROPT parameter)
- Selecting members to copy
- Selecting the records to copy
Copying across different formats and systems
- Copying between different database record formats (FMTOPT parameter). You can copy from a source file to a data file or from a data file to a source file. If the from-file or to-file is a device file, this function is automatic. If both files are database files, specify FMTOPT(CVTSRC). If either file is a device file or inline data file, the FMTOPT parameter does not apply.
- Copying between different systems. This is especially important when you are using data warehousing, and when you want to use existing export products from other platforms to move data to the System i platform.
Making 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.
- Printing records (PRINT, OUTFMT, and TOFILE(*PRINT) parameters)
- Adding or changing source file sequence number and date fields (SRCOPT and SRCSEQ parameters)
- Preventing errors when copying files
- Performance
Parent topic:
Copying files
Related concepts
Copying files: Overview
Creating the to-file (CRTFILE parameter)
Selecting members to copy
Adding, replacing, and updating records (MBROPT parameter)
Selecting the records to copy
Related information
CPYF command
CPYFRMQRYF command