Moving data between systems using copy file commands
Another way to move data from one IBM i operating system to another is to copy the data using the copy file commands with DDM.
You can use the Copy File (CPYF), Copy Source File (CPYSRCF), and Copy From Query File (CPYFRMQRYF) commands to copy data between files on clients and servers. You can copy local relational database or device files from (or to) remote database files, and remote files can also be copied to remote files.
For example, if a dealership closes, the distributed relational database administrator can copy the client and inventory tables from the remote system to the local regional system. The administrator needs a properly authorized user profile on the server to access and copy the tables and must create a DDM file on the client for each table or file that is copied. The following example shows the command that the database administrator uses to copy a table called INVENT in a collection called SPIFFY from a system with a remote location name of KC105 to a regional center system called KC000. A DDM file called INCOPY in a library called TEST on the KC000 client is used for the file access. These commands are run on the KC000 system:
CRTDDMF FILE(TEST/INCOPY) RMTFILE(SPIFFY/INVENT)
RMTLOCNAME(KC105)
CPYF FROMFILE(TEST/INCOPY) TOFILE(TEST/INVENTDDM)
MBROPT(*ADD)
In this example, the administrator runs the commands on the KC000 system. If the administrator is not on the KC000 system, then pass-through must be used to run these commands on the KC000 system. The Submit Remote Command (SBMRMTCMD) command cannot be used to run the preceding commands because the IBM i operating system cannot be a client and a server for the same job.
Consider the following items when using this command with DDM:
- A DDM file can be specified on the FROMFILE and the TOFILE parameters
for the Copy File (CPYF) command and Copy Source File (CPYSRCF) commands.
Note: For the Copy From Query File (CPYFRMQRYF) and Copy from Tape (CPYFRMTAP) commands, a DDM file name can be specified only on the TOFILE parameter; for the Copy to Tape (CPYTOTAP) command, a DDM file name can be specified only on the FROMFILE parameter.
- When a delete-capable file is copied to a non-delete capable file, you must specify COMPRESS(*YES), or an error message is sent and the job ends.
- If the remote file name on a DDM file specifies a member name, the member name specified for that file on the Copy File (CPYF) command must be the same as the member name on the remote file name on the DDM file. In addition, the Override with Database File (OVRDBF) command cannot specify a member name that is different from the member name on the remote file name on the DDM file.
- If a DDM file does not specify a member name and if the Override with Database File (OVRDBF) command specifies a member name for the file, the Copy File (CPYF) command uses the member name specified on the OVRDBF command.
- If the TOFILE parameter is a DDM file that refers to a file that
does not exist, CPYF creates the file. Keep the following special
considerations for remote files created with the Copy File (CPYF)
command in mind:
- The user profile for the target DDM job must be authorized to the Create Physical File (CRTPF) command on the server.
- For an IBM i server system, the TOFILE parameter has all the attributes of the FROMFILE parameter except those described in the Database file management topic collection.
- When using TCP/IP, the second element of the RMTLOCNAME parameter of the Create Distributed Data Management File (CRTDDMF) command must be *IP.