CPYSRCF (Copy Source File)

CPYSRCF Command syntax diagram

 

Purpose

The Copy Source File (CPYSRCF) command copies a database source file or DDM file to a physical source file or DDM file and converts the data character 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 Data Management topic in the Information Center.

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 offers a subset of the parameters available on the 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

  1. A file's open data path (ODP) cannot be shared with any other program in the job (routing step) during the the copy operation.
  2. In multithreaded jobs, this command is not threadsafe when copying from or to multiple database file members, device files (except SPOOL(*YES) print files), distributed files, or DDM files of type *SNA. This command fails for distributed files that use relational databases of type *SNA and DDM files of type *SNA. It is threadsafe ONLY when copying from and to single database file members (local or DDM of type *IP) or SPOOL(*YES) print files.

 

Required Parameters

FROMFILE
Specifies the qualified name of the database source file that contains the records being copied.

The name of the database source file can be qualified by one of the following library values:

*LIBL: All libraries in the job's library list are searched until the first match is found.

*CURLIB: The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.

library-name: Specify the name of the library to be searched.

database-source-file-name: Specify the name of the database source file that contains records being copied.

TOFILE
Specifies the qualified name of the file that receives the copied records.

*PRINT: The records are copied to the IBM-supplied printer file QSYSPRT and listed in an SEU-type source file format. No CCSID conversions occur if *PRINT is specified. The format includes no blank lines between records, source fields separated from the data, and members listed in alphabetic order. If the listing needs to be in hexadecimal format, use the Copy File (CPYF) command with the OUTFMT(*HEX) parameter value. The IBM-supplied printer file QSYSPRT may not be overridden to a different file name, and it must have the RPLUNPRT(*YES) and CTLCHAR(*NONE) attributes.

The name of the to-file can be qualified by one of the following library values:

*LIBL: All libraries in the job's library list are searched until the first match is found.

*CURLIB: The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.

library-name: Specify the name of the library to be searched.

to-file-name: Specify the name of the physical source file that receives the copied records. (If no library qualifier is given, *LIBL is used to find the file.)

FROMMBR
Specifies the members copied from the from-file. A single member, a generic set of members, or all members in the from-file are copied. Members are copied and listed in alphabetic order.

*ALL: All members in a database file are copied.

*FIRST: The first member (by creation date) in the database file is copied.

from-member-name: Specify the name of the database file member that is copied.

generic*-member-name: Specify the generic name of the group of members that are copied. A generic name is a character string of one or more characters followed by an asterisk (*); for example, ABC*. The asterisk substitutes for any valid characters. A generic name specifies all objects with names that begin with the generic prefix for which the user has authority. If an asterisk is not included with the generic (prefix) name, the system assumes it to be the complete object name. See generic names for additional information.

 

Optional Parameters

TOMBR
Specifies the name of the file member that receives the copied records.

Note: If a member (specified by a name or implied by a parameter value of *FROMMBR) does not exist in the to-file, it is added to the to-file by the copy operation. Either *FROMMBR or *FIRST must be specified for this parameter if the to-file is *PRINT.

*FROMMBR: The members specified by the FROMMBR parameter are copied into corresponding members in the to-file. If a member with a corresponding name does not exist in the to-file, a member with that name is added to the to-file.

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.

*FIRST: The first member in the database to-file receives the copied records.

to-member-name: Specify the name of the member that receives the records copied from the from-file. If a member with the specified name does not exist, one with the same name is added.

MBROPT
Specifies whether the new records replace or are added to the existing records.

*REPLACE: The system clears the existing member and adds the new records.

*ADD: The system adds the new records to the end of the existing records.

SRCOPT
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. New values can be specified in either or both fields.

*SAME: The value does not change.

*SEQNBR: Sequence number and increment values for the sequence number field in the records being copied are assigned as specified in the SRCSEQ parameter.

*DATE: The date fields in the records being copied are reset to six zeros.

SRCSEQ
Specifies the starting and increment values used for creating sequence numbers for the source sequence number field in the records copied. The maximum value for sequence number is 9999.99; if a value is larger than this limit, additional records in the member are assigned the sequence number 9999.99. The SRCSEQ parameter is ignored unless SRCOPT(*SEQNBR) is specified.

Element 1: Starting Value

1.00: Specifies that the records being copied to the database file start with a first sequence number of 1.00, and are numbered in increments of 1.00.

starting-sequence-number: Specify the value assigned to the sequence number field for the first record copied. Any value within the range of 0.01 to 9999.99 may be specified.

Element 2: Increment Value

1.00: Specifies that the records being copied to the database file start with a first sequence number of 1.00, and are numbered in increments of 1.00.

increment-number: Specify the value by which the sequence number is incremented for each of the following records copied. Any value in the range of 0.01 to 9999.99 may be specified. Once the maximum sequence number of 9999.99 is reached, the sequence number of additional records is 9999.99.

Examples for CPYSRCF

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.

Error messages for CPYSRCF

*ESCAPE Messages

CPF2816
File &1 in &2 not copied because of error.
CPF2817
Copy command ended because of error.
CPF2858
File attributes not valid for printed output.
CPF2859
Shared open data path not allowed.
CPF2864
Not authorized to file &1 in library &2.
CPF2875
Wrong file member or label opened.
CPF2888
Member &3 not added to file because of error.
CPF2909
Error clearing member &3 in file &1 in &2.
CPF2949
Error closing member &3 in file &1 in &2.
CPF2952
Error opening file &1 in library &2.
CPF2968
Position error occurred copying file &1 in &2.
CPF2971
Error reading member &3 in file &1.
CPF2972
Error writing to member &3 in file &1.
CPF3140
Initialize or copy of member &2 canceled.
CPF3143
Increments not allowed for member &2.
CPF3148
New records need too much space for member &2.
CPF3150
Data base copy failed for member &2.
CPF9212
Cannot load or unload DDM file &2 in &3.