| Where allowed to run: All environments (*ALL) Threadsafe: Conditional |
Parameters Examples Error messages |
The Copy Source File (CPYSRCF) command copies a database source file or DDM file to a source physical file or DDM file and converts the character data from the from-file CCSID to the to-file CCSID. If TOFILE(*PRINT) is specified, a formatted printer file is created by using the IBM-supplied printer file QSYSPRT (the file is changed for source records and is different from other copy command file formats). Any overrides issued for the from-file or to-file apply to the files used in the copy operation. Record data is copied from the from-file to the to-file, converting character data from the from-file CCSID to the to-file CCSID. Other differences in record formats (like that of the FMTOPT(*NOCHK) parameter option on the CPYF command) are disregarded.
Note: For more information on DDM files, see the Distributed database programming topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
One member, all members, or a generic set of members can be copied each time the command is called. From-file members can be copied to like-named to-file members or to a single to-file member. Many members are copied and listed in alphabetical order. The to-file must exist when the CPYSRCF command is started. This command does not create the to-file, but it does add a member to an existing physical file if the member does not already exist in the to-file.
This command provides similar support as the Copy File (CPYF) command. Note that the default for the MBROPT parameter is *REPLACE (unlike other copy commands), which clears existing records in the receiving member of the to-file before replacing them with records copied from the from-file. Also, the default for the TOMBR parameter is *FROMMBR, which causes from-file members to be copied to like-named to-file members.
Restrictions:
| Top |
| Keyword | Description | Choices | Notes |
|---|---|---|---|
| FROMFILE | Data base source file | Qualified object name | Required, Positional 1 |
| Qualifier 1: Data base source file | Name | ||
| Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
| TOFILE | To file | Single values: *PRINT Other values: Qualified object name |
Required, Positional 2 |
| Qualifier 1: To file | Name | ||
| Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
| FROMMBR | From member | Generic name, name, *FIRST, *ALL | Required, Positional 3 |
| TOMBR | To member or label | Name, *FROMMBR, *FIRST | Optional, Positional 4 |
| TOMBRID | To member identifier | *GEN, *FROMMBR | Optional |
| MBROPT | Replace or add records | *REPLACE, *ADD | Optional, Positional 5 |
| SRCCHGDATE | Source change date | *FROMMBR, *NEW | Optional |
| TEXT | Text 'description' | *SAME, *FROMMBR | Optional |
| SRCTYPE | Source type | *SAME, *FROMMBR | Optional |
| SRCOPT | Source update options | Single values: *SAME Other values (up to 2 repetitions): *SEQNBR, *DATE |
Optional |
| SRCSEQ | Source sequence numbering | Element list | Optional |
| Element 1: Starting sequence number | 0.01-9999.99, 1.00 | ||
| Element 2: Increment number | 0.01-9999.99, 1.00 |
| Top |
Specifies the database source file that contains the records to be copied.
This is a required parameter.
Qualifier 1: Data base source file
Qualifier 2: Library
| Top |
Specifies the file that receives the copied records.
This is a required parameter.
Single values
Qualifier 1: To file
Qualifier 2: Library
| Top |
Specifies the file member(s) copied from the from-file. A single member, a generic set of members, or all members in the from-file can be copied. Members are copied in alphabetical order.
This is a required parameter.
| Top |
Specifies the name of the file member that receives the copied records.
If *PRINT is specified for the To file (TOFILE) parameter, either *FIRST or *FROMMBR must be specified for this parameter.
If a member name or *FIRST was specified as a value for the FROMMBR parameter, then a member in the to-file with the same name receives the records copied. If *ALL or a generic member name is specified as a value for the FROMMBR parameter, each member in the from-file is copied into a member with the same name in the to-file. Records from one or more members (specified by the FROMMBR parameter) in the from-file are copied to the first member in the to-file.
| Top |
Specifies, for new members added to the to-file, whether the member level identifer will be generated or copied from the member level identifier of the member in the from-file.
| Top |
Specifies whether the new records replace or are added to the existing records.
| Top |
Specifies, for new members added to the to-file, or if MBROPT(*REPLACE) was specified, whether the 'Last source update date/time' will be a new date/time, or copied from the 'Last source update date/time' of the member in the from-file.
| Top |
Specifies if the MBROPT(*REPLACE) was specified, whether the text describing the member will be copied from the from-member.
| Top |
Specifies if the MBROPT(*REPLACE) was specified, whether the source type of the to-member will be copied from the from-member.
| Top |
Specifies whether new values are assigned to the source sequence number and date fields when records from the from-file are copied to the to-file.
Single values
Other values (up to 2 repetitions)
| Top |
Specifies, only when *SEQNBR is also specified for the Source update options (SRCOPT) parameter, the sequence number to be used in the first copied record and the value to be added to the initial sequence number to calculate the sequence number for each subsequent copied record. The maximum value for a sequence number is 9999.99; if a value is larger than this limit, additional records in the member are all assigned the sequence number 9999.99.
Element 1: Starting sequence number
Element 2: Increment number
| Top |
Example 1: Replacing Existing Records
CPYSRCF FROMFILE(QGPL/QCLSRC) TOFILE(MYLIB/CLSRC)
FROMMBR(PGMA)
This command copies records from member PGMA of database source file QCLSRC which is in the QGPL library. The defaults for the TOMBR and MBROPT parameters are taken so the records are copied to a like-named member (PGMA) of CLSRC in library MYLIB and replaces existing records in the member. If member PGMA does not exist in the to-file, it is added as part of the copy operation. If the CCSID of QGPL/QCLSRC is different from the CCSID of MYLIB/CLSRC, the character data is converted to the CCSID of CLSRC.
Example 2: Printing Files
CPYSRCF FROMFILE(QRPG/QRPGSRC) TOFILE(*PRINT) FROMMBR(INV*)
This command copies from database source file QRPGSRC in library QRPG, all file members whose names start with the characters INV. Special value *PRINT is specified for the to-file, so the records are copied to the printer and listed in a format tailored to source records, much like the printout created by SEU. Character data is not converted when specifying TOFILE(*PRINT).
Example 3: Changing the Increment Value
CPYSRCF FROMFILE(MYLIB/TXTSRC) TOFILE(QIDU/QTXTSRC)
FROMMBR(*ALL) SRCOPT(*SEQNBR *DATE) SRCSEQ(1 .25)
This command copies all the members of database source file TXTSRC in library MYLIB. They are copied and replace (by using the default MBROPT(*REPLACE)) the existing records in like-named members (by using default TOMBR(*FROMMBR)) of data source file QTXTSRC in library QIDU. If the to-file members do not exist, they are added by the copy operation. For each member copied, the first record is numbered 1 and each following number is incremented by 0.25. Also, the source date field is set to zero in each record. If the CCSID of MYLIB/TXTSRC is different from the CCSID of QIDU/QTXTSRC, the character data is converted to the CCSID of QIDU/QTXTSRC.
| Top |
*ESCAPE Messages
| Top |