Use CPYF Command Similar to COPY Command in DOS

One of the most powerful commands on the AS/400 is the Copy File command. To use it, key CPYF and hit F4.

To copy the file ABC from MYLIB to ABCBKUP in MYLIB, fill in the screen like this:

 
                               Copy File (CPYF) 
                                                
Type choices, press Enter.                      
                                                
From file  . . . . . . . . . . .   ABC          
  Library  . . . . . . . . . . .     MYLIB      
To file  . . . . . . . . . . . .   ABCBKUP      
  Library  . . . . . . . . . . .     MYLIB      
From member  . . . . . . . . . .   *FIRST       
To member or label . . . . . . .   *FIRST       
Replace or add records . . . . .   *NONE        
Create file  . . . . . . . . . .   *YES         
Print format . . . . . . . . . .   *CHAR        
Notice, the "Create File" option is *YES.

To copy ABCBKUP back to ABC and replace the existing file, change the "Replace or add records" to *REPLACE and leave the "Create File" as *NO:

 
                                Copy File (CPYF)
                                                
 Type choices, press Enter.                     
                                                
 From file  . . . . . . . . . . .   ABCBKUP     
   Library  . . . . . . . . . . .     MYLIB     
 To file  . . . . . . . . . . . .   ABC         
   Library  . . . . . . . . . . .     MYLIB     
 From member  . . . . . . . . . .   *FIRST      
 To member or label . . . . . . .   *FIRST      
 Replace or add records . . . . .   *REPLACE    
 Create file  . . . . . . . . . .   *NO         
 Print format . . . . . . . . . .   *CHAR       
Hit F10 to see the 5 extra screens of options. Use PAGE DOWN to get to the different screens.

To copy only 100 records, key 100 in the "Copy to Record Number" parameter. Or, use the "Number of records to copy" parameter.

To add data from the file ABC01 to ABC, use *ADD for "Replace or add records":


                                Copy File (CPYF) 
                                                 
 Type choices, press Enter.                      
                                                 
 From file  . . . . . . . . . . . > ABC01        
   Library  . . . . . . . . . . . >   MYLIB      
 To file  . . . . . . . . . . . . > ABC          
   Library  . . . . . . . . . . . >   MYLIB      
 From member  . . . . . . . . . .   *FIRST       
 To member or label . . . . . . .   *FIRST       
 Replace or add records . . . . . > *ADD         
 Create file  . . . . . . . . . . > *NO          
 Print format . . . . . . . . . .   *CHAR        




Back to Basic AS/400 Tips    |    Back to Main Page    |   Contact Info