Copy a Subset of Records from One System to Another
September 27, 2006 Ted Holt
Recently, I needed an easy way to refresh a development system with a subset of records from a file on a production system. I needed a method that I could run unattended, during off hours. FTP, the Save-Restore commands, and the third-party file transfer utilities available to me are good tools, but they have their drawbacks. All of them require me to transfer complete files, even if I only want to transfer a subset of records. And it is difficult to determine whether FTP succeeds or fails in a batch job. I found an easy way to accomplish my goal. First I created a DDM file on the production system to point to the target system. CRTDDMF FILE(MYLIB/MYDATA) RMTFILE(MYLIB/MYDATA) + RMTLOCNAME(DEVELOP *SNA) I chose to give the DDM file the same name as the production file. In this example, I use the file name MYDATA. So, DDM file MYLIB/MYDATA on the production system points to file MYLIB/MYDATA on system DEVELOP. To refresh the file on the development system requires me to run a simple Copy File (CPYF) command on the production system. Here I copy from the production database to the DDM file, selecting records in batch 151 only. CPYF FROMFILE(PRODUCTION/MYDATA) TOFILE(MYLIB/MYDATA) + MBROPT(*REPLACE) INCREL((*IF BATCH *EQ 151)) Or, I can use the Copy from Query File (CPYFRMQRFY) command. OPNQRYF FILE((PRODUCTION/MYDATA)) QRYSLT('batch=170') CPYFRMQRYF FROMOPNID(MYDATA) TOFILE(MYLIB/MYDATA) MBROPT(*REPLACE) CLOF OPNID(MYDATA) RELATED STORIES |