Copy files: supported functions

iSeries™ provides many copy functions for database files and copy functions for device files. Each function has associated parameters and files types.

The following tables, (Table 1 and Table 2), provide a summary of the specific copy functions (using the copy commands) you can use for copying records by the types of files being copied from and to. The functions with their associated parameters are listed down the left side, and the file types (and if each can be a from-file and a to-file) are shown across the top. An X indicates that the associated parameter is valid for the type and use of file under which it occurs.

Table 1. Summary of Copy Functions for database files
Copy function Parameter Database files1
Physical Logical
From To From To
Select files FROMFILE2 X   X  
TOFILE   X    
Select members FROMMBR X   X  
TOMBR   X    
Add to, replace, or update existing records MBROPT   X    
Create the to-file CRTFILE3 X X X  
Print copied, excluded, and error records PRINT4 X X X  
Select by record format RCDFMT     X  
Select by relative record number FROMRCD X   X5  
TORCD X   X5  
Select by key field value FROMKEY X   X  
TOKEY X   X  
Specify number of records to copy NBRRCDS X   X  
Select by character content INCCHAR X   X  
Select by field value INCREL X   X  
Process different database record formats FMTOPT X X X  
Update sequence number and date SRCOPT X X X  
Specify start value and increment SRCSEQ X X X  
Print character and hex format OUTFMT4 X X X  
Maximum recoverable errors allowed ERRLVL X X X  
Disregard or include deleted records COMPRESS6 X X    
Note:
1
DDM files will appear to act like database files, with exceptions noted in the Distributed Data Management book.
2
On the CPYFRMQRYF command, the FROMOPNID parameter is used to identify an open identifier for the open query file to be copied from. The FROMFILE parameter is used in all other copy commands.
3
If the to-file does not exist before the copy operation and the from-file is a physical or logical file, the copy operation will create a physical file as the to-file if you specified CRTFILE(*YES) on the copy commands.
4
You can specify a program-described printer file so that the copy will produce a list with no special formatting or page headings, or you can specify TOFILE(*PRINT) to produce a formatted list. You can specify PRINT(*COPIED) to produce a formatted list of the copied records, you can specify PRINT(*EXCLD) to produce a formatted list of the records excluded by the INCCHAR or INCREL parameters, and you can specify PRINT(*ERROR) to produce a formatted list of records causing ERRLVL errors. When you request a list by specifying the TOFILE(*PRINT) parameter, the OUTFMT parameter specifies whether the data is printed in character or in both character and hexadecimal form.
5
You can specify the FROMRCD and TORCD parameter values for a logical file if it has an arrival sequence access path.
6
You cannot specify COMPRESS(*NO) if:
  • The to-file member or a logical file member based on the to-file member has a keyed access path with any of the following attributes:
    • Unique keys (UNIQUE keyword specified in the DDS)
    • Floating-point key field or logical numeric key field and not MAINT(*REBLD)
    • Select/omit specifications in the DDS (without the DYNSLT keyword specified) and not MAINT(*REBLD)
  • Field-level mapping or source/data conversion is required (FMTOPT parameter).
  • An EOFDLY wait time is specified for the from-file on an Override Database File (OVRDBF) command.
Note: To copy deleted records, the from-file must be processed in arrival sequence.
Table 2. Summary of Copy functions for device files
Copy function Parameter Device Files
Inline data Diskette Tape Printer
From To From To From To From To
Select files FROMFILE X   X   X      
TOFILE       X   X   X
Select members FROMMBR     X   X      
TOMBR       X   X    
Add to or replace existing records MBROPT                
Create the to-file CRTFILE                
Print copied or excluded records PRINT2 X   X X X X   X
Select by record format RCDFMT                
Select by relative record number FROMRCD X   X   X      
TORCD X   X   X      
Select by key field value FROMKEY                
TOKEY                
Specify number of records to copy NBRRCDS X   X   X      
Select by character content INCCHAR X   X   X      
Select by field value INCREL                
Process different database record formats FMTOPT                
Update sequence number or date SRCOPT                
Specify start value and increment SRCSEQ                
Print character or hex format OUTFMT2 X   X X X X   X
Maximum recoverable errors allowed ERRLVL         X      
Disregard or include deleted records COMPRESS                
Notes:
1
You can specify a program-described printer file so that the copy will produce a list with no special formatting or page headings, or you can specify TOFILE(*PRINT) to produce a formatted list. You can specify PRINT(*COPIED) to produce a formatted list of the copied records, you can specify PRINT(*EXCLD) to produce a formatted list of the records excluded by the INCCHAR or INCREL parameter, and you can specify PRINT(*ERROR) to produce a formatted list of records causing ERRLVL errors. When you request a list by specifying the TOFILE(*PRINT) parameter, the OUTFMT parameter specifies whether the data is printed in character or in both character and hexadecimal form.