Copy To Import File (CPYTOIMPF)
Where allowed to run: All environments (*ALL)
Threadsafe: NoParameters
Examples
Error messagesThe Copy To Import File (CPYTOIMPF) command copies an externally-described file to an import file. The term import file is used to describe a file created for purposes of copying data between heterogeneous databases. The import file (TOSTMF or TOFILE parameter) will be called the to-file for this command.
Some of the specific functions that can be performed by the CPYTOIMPF command include the following:
- Copying from an externally described physical file to the to-file (TOFILE or TOSTMF parameter).
- Adding records to an existing to-file member or replacing the contents of the to-file member (MBROPT parameter).
Error Handling: The escape message CPF2817 is sent for many different error conditions that can occur during a copy operation. At least one diagnostic message that indicates the specific error condition always comes before the escape message. More information on handling errors is in the Files and file systems topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Overrides: All overrides are in effect for this command. The parameters of the overrides that are supported by CPYTOIMPF are:
Status Message: During the running of the CPYTOIMPF command, message CPI2801 is sent as a status message informing the interactive user that a copy is occurring. More information on preventing status messages from appearing is in the Files and file systems topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Restrictions:
- During the time a CPYTOIMPF request is run, the file specified for the To data base file (TOFILE) parameter may be locked (similar to an *EXCL lock with no timeout) so that no access is possible.
- If the from-file has the SHARE(*YES) attribute, unpredictable results can occur. Therefore, if the from-file is defined with SHARE(*YES), the user should make sure the file is not opened by any process prior to the copy.
Top
Parameters
Keyword Description Choices Notes FROMFILE From file Element list Required, Positional 1 Element 1: File Qualified object name Qualifier 1: File Name Qualifier 2: Library Name, *LIBL, *CURLIB Element 2: Member Name, *FIRST, *ALL TOFILE To data base file Element list Optional, Positional 2 Element 1: File Qualified object name Qualifier 1: File Name Qualifier 2: Library Name, *LIBL, *CURLIB Element 2: Member Name, *FIRST, *FROMMBR, *ALL TOSTMF To stream file Path name Optional, Positional 3 MBROPT Replace or add records *ADD, *REPLACE Optional FROMCCSID From CCSID 1-65533, *FILE Optional TOCCSID To CCSID 1-65533, *FILE Optional STMFCODPAG Stream file code page 1-32767, *STMF, *PCASCII, *STDASCII Optional RCDDLM Record delimiter Character value, *EOR, *CRLF, *LF, *CR, *LFCR Optional DTAFMT Record format of import file *DLM, *FIXED Optional STRDLM String delimiter Character value, *DBLQUOTE, *NONE Optional STRESCCHR String escape character Character value, *STRDLM, *NONE Optional RMVBLANK Remove blanks *NONE, *LEADING, *TRAILING, *BOTH Optional FLDDLM Field delimiter Character value, ',', *TAB Optional NULLIND Null field indicator *NO, *YES Optional DECPNT Decimal point *PERIOD, *COMMA Optional DATFMT Date format *ISO, *USA, *EUR, *JIS, *YYMD Optional TIMFMT Time format *ISO, *USA, *EUR, *JIS Optional
Top
From file (FROMFILE)
Specifies the file that contains the records to be copied. The database file can be a single-format logical, physical, or multi-system file.
This is a required parameter.
Element 1: File
Qualifier 1: File
- name
- Specify the name of the file that contains the records to be copied.
Qualifier 2: Library
- *LIBL
- All libraries in the library list for the current thread are searched until the first match is found.
- *CURLIB
- The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched.
- name
- Specify the name of the library to be searched.
Element 2: Member
- *FIRST
- The first member (in order of creation date) in the specified from-file is used. Specifying *FIRST is not allowed if the from-file has no members.
- *ALL
- All members of the specified file are copied.
- name
- Specify the name of the from-file member containing the records to copy.
Top
To data base file (TOFILE)
Specifies the database file to receive the copied records. Either this parameter or the TOSTMF parameter is required.
The to-file can be any of the following file types:
- source physical file
- program-described physical file
- externally-described physical file with one non-numeric field.
Element 1: File
Qualifier 1: File
- name
- Specify the name of the file to receive the copied records.
Qualifier 2: Library
- *LIBL
- All libraries in the library list for the current thread are searched until the first match is found.
- *CURLIB
- The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched.
- name
- Specify the name of the library to be searched.
Element 2: Member
- *FIRST
- The first member (in order of creation date) in the specified to-file is used.
Specifying *FIRST is not allowed if the specified to-file has no members and there is no override (OVRDBF command) in effect that specified a member name for the to-file.
- *ALL
- The data is copied to the correct to-member of the partitioned table. *ALL is only valid for partitioned tables.
- *FROMMBR
- Corresponding from-file and to-file member names are used.
- name
- Specify the name of the to-file member to receive the copied records. If a member with the specified name does not already exist in the to-file, the member will be added.
Top
To stream file (TOSTMF)
Specifies the output stream file to which data is to be copied. Either this parameter or the TOFILE parameter is required. All directories in the path name must exist. New directories are not created. If the stream file does not exist, it will be created.
The QSYS.LIB file system does not allow attributes to be set, so if the path name specified on the TOSTMF parameter is a QSYS member, diagnostic messages will appear in the joblog. The diagnostic messages will not prevent the copy operation from completing successfully.
- path-name
- Specify the path name of the output stream file to which data is to be copied.
Top
Replace or add records (MBROPT)
Specifies whether the copy operation replaces, adds, or fails to copy to the records in the to-file member if a member with the specified name already exists. If the member does not exist, it is created and added to the to-file.
If *ADD is specified and the to-file contains no records, the copy operation completes normally. If *REPLACE is specified and the to-file contains no records, the copy operation ends abnormally.
Additional information is available in the Files and file systems topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
- *ADD
- The copied records are added to the end of the existing member records.
- *REPLACE
- The copied records replace the existing member records.
Top
From CCSID (FROMCCSID)
Specifies the coded character set identifier (CCSID) to use for the from-file fields.
- *FILE
- The data is converted from the from-file field CCSID. If the CCSID of the from-file field is 65535, the field is not converted and it is treated as binary data.
- 1-65533
- Specify the CCSID to be used when the CCSID of the from-file field is 65535. If the CCSID of the from-file field is not 65535, this parameter is ignored.
Top
To CCSID (TOCCSID)
Specifies the coded character set identifier (CCSID) to use for the file specified for the To data base file (TOFILE) parameter.
- *FILE
- The CCSID of the to-file database file is used.
- 1-65533
- Specify the CCSID to be used when the CCSID of the to-file is 65535. If the to-file CCSID is not 65535, an error message will be sent.
Top
Stream file code page (STMFCODPAG)
Specifies the method of obtaining the stream file code page and the coded character set identifier (CCSID) equivalent of the code page that is used for data conversion.
- *STMF
- If the stream file exists, and data conversion is requested, the CCSID equivalent of the code page associated with the stream file is used to perform the conversion.
If the stream file does not exist, the code page equivalent of the source database file CCSID is used and associated with the stream file.
- *STDASCII
- If the stream file exists, this option is valid only if the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a code page in the IBM PC Data encoding scheme (x2100) is computed. This code page is associated with the target stream file and is used for data conversion if it is requested.
- *PCASCII
- If the stream file exists, this option is valid only if the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a code page in the Microsoft Windows encoding scheme (x4105) is computed. (Microsoft and Windows are registered trademarks of Microsoft Corporation). This code page is associated with the target stream file and is used for data conversion if it is requested. This option allows the resulting data to be used by Microsoft Windows applications.
- 1-32767
- Specify the code page to be used. If the stream file exists, this option is only valid if the code page associated with the stream file is the same as the specified value. Otherwise, an error message is sent. If the stream file does not exist, the specified code page is associated with the stream file when it is created.
Top
Record delimiter (RCDDLM)
Specifies the record delimiter of the to-file.
If the TOFILE parameter is specified, valid values are *EOR or a character value. If the TOSTMF parameter is specified, valid values are *CR, *CRLF, *LF, *LFCR or *ALL.
- *EOR
- End of record and the data after the last field will be padded with X'00'.
- *CRLF
- Carriage-return followed by line-feed is appended to the end of the line.
- *LF
- Line-feed is appended to the end of the line.
- *CR
- Carriage-return is appended to the end of the line.
- *LFCR
- Line-feed followed by carriage-return is appended to the end of the line.
- character-value
- Specify the single character which indicates the end of a single record.
Top
Record format of import file (DTAFMT)
Specifies the format of the data of the generated to-file.
- *DLM
- The data contains delimiter characters. Refer to parameter descriptions for STRDLM, FLDDLM, and RCDDLM for information on string, field, and record delimiter characters.
- *FIXED
- The data format is fixed. The data is in fixed columns in each record. Refer to the Null field indicator (NULLIND) parameter for more information on how null fields will appear in the to-file.
Top
String delimiter (STRDLM)
Specifies the string delimiter for the data of the fields being copied to. This character indicates the start and end of character, date, time, and timestamp strings in the to-file. Depending on the utility used to create the to-file, some types of strings may appear in the to-file without string delimiter characters.
The specified delimiter character will be converted from the coded character set identifier (CCSID) of the job to the CCSID of the to-file. If the to-file CCSID is 1200, 1208, or 13488 the delimiter is converted to the job CCSID, or to the job's default CCSID when the job CCSID is 65535.
- *DBLQUOTE
- The double quote character is used as the string delimiter.
- *NONE
- No delimiter is expected as the string delimiter. The blank character ( ) represents the *NONE value.
- character-value
- Specify the character value for the string delimiter.
Top
String escape character (STRESCCHR)
Specifies the escape character to be generated within string fields in the to-file. Character fields in the to-file may contain characters that have a special meaning to the import utility. These characters include the string delimiter and the string escape character itself.
The string escape character precedes such characters in the to-file data and revokes their special meaning. The import utility can then determine if the character is data or a string delimiter.
The specified string escape character will be converted from the coded character set identifier (CCSID) of the job to the CCSID of the to-file. If the to-file CCSID is 1200, 1208, or 13488 the string escape character is converted to the job CCSID, or the job's default CCSID when the job CCSID is 65535.
- *STRDLM
- The string delimiter is used as the escape character. Each string delimiter in a from-file character field is exported as two adjacent string delimiters.
- *NONE
- No string escape character is inserted in the data. If the string delimiter character is present in the data, unexpected results could occur in the import utility that relies on the to-file.
- character-value
- Specify the character to be used as the escape character.
Top
Remove blanks (RMVBLANK)
Specifies whether blanks are removed or retained. This parameter is ignored when the DTAFMT parameter is set to *FIXED.
- *NONE
- All leading and trailing blanks are retained.
- *LEADING
- Leading blanks are removed.
- *TRAILING
- Trailing blanks are removed.
- *BOTH
- Leading and trailing blanks are removed.
Top
Field delimiter (FLDDLM)
Specifies the field delimiter for the record. This value is placed between fields.
- ','
- A comma is used as the field delimiter.
- *TAB
- The horizontal tab character is used as field delimiter.
- character-value
- Specify the character value for the field delimiter.
Top
Null field indicator (NULLIND)
Specifies whether the first character following each field will contain either a Y or N indicating if the field is null. NULLIND(*YES) is only valid if *FIXED is specified for the Record format of import file (DTAFMT) parameter.
- *NO
- Do not add the null value indicator character after each field.
- *YES
- Add the null value indicator character after each field in the generated fixed-format to-file.
Top
Decimal point (DECPNT)
Specifies the decimal point character to be used when copying numeric data to the to-file.
- *PERIOD
- A period (.) is used for the decimal point character.
- *COMMA
- A comma (,) is used for the decimal point character.
Top
Date format (DATFMT)
Specifies the date format to be used when copying date fields to the to-file.
- *ISO
- The International Organization for Standardization (ISO) date format yyyy-mm-dd is used.
- *USA
- The United States date format mm/dd/yyyy is used.
- *EUR
- The European date format dd.mm.yyyy is used.
- *JIS
- The Japanese Industrial Standard date format yyyy-mm-dd is used.
- *YYMD
- The date format yyyymmdd is used.
Top
Time format (TIMFMT)
Specifies the time format to be used when copying time fields to the to-file.
- *ISO
- The International Organization for Standardization (ISO) time format hh.mm.ss is used.
- *USA
- The United States time format hh:mmxx is used, where xx is AM or PM.
- *EUR
- The European time format hh.mm.ss is used.
- *JIS
- The Japanese Industrial Standard time format hh:mm:ss is used.
Top
Examples
CPYTOIMPF FROMFILE(DB2FILE) TOFILE(EXPFILE) FLDDLM(';') RCDDLM(X'07') STRDLM(*DBLQUOTE) DATFMT(*JIS) TIMFMT(*JIS)All records of externally described file DB2FILE will be copied to import file EXPFILE. Fields in the import file will be delimited by semi-colon (;) characters. Each record in the import file will be delimited by a hexadecimal '07' character. Character, date, time, and timestamp values will begin and end with the double quote character. Date and time fields will be in the *JIS format.
Top
Error messages
*ESCAPE Messages
- CPF2817
- Copy command ended because of error.
Top