Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Copy From Stream File (CPYFRMSTMF) command copies the data in a stream file to either a database file member or a save file. Optional conversion of the data and reformatting is performed when copying a database file member. This command cannot be used to copy to or from a database file member on a remote system. Any overrides in effect for the database file member or the save file are not used by this command.
This command can operate on regular files and on the /dev/null character special file. A regular file is a file that supports the integrated file system input/output (I/O) operations open, read, and write.
For more information about integrated file system commands, see the Integrated file system information in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Note: The sequence numbers in the resulting database file member may be out of order. If a function will be used that requires the sequence numbers to be ordered, use the Reorganize Physical File Member (RGZPFM) command on the member, with the SRCOPT(*SEQNBR) parameter specified.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
FROMSTMF | From stream file | Path name | Required, Positional 1 |
TOMBR | To file member or save file | Path name | Required, Positional 2 |
MBROPT | Member option | *NONE, *ADD, *REPLACE | Optional |
CVTDTA | Data conversion options | *AUTO, *TBL, *NONE | Optional |
STMFCODPAG | Stream file code page | 1-32767, *STMF, *PCASCII | Optional |
DBFCCSID | Database file CCSID | 1-65533, *FILE | Optional |
TBL | Conversion table | Path name | Optional |
ENDLINFMT | End of line characters | *ALL, *CRLF, *LF, *CR, *LFCR, *FIXED | Optional |
TABEXPN | Tab character expansion | *YES, *NO | Optional |
Top |
Specifies the path name of the stream file from which data is copied. This command can operate on files of type *STMF and on the /dev/null character special file.
For more information on specifying path names, refer to "Object naming rules" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
Specifies the path name of the database file member or save file to which data is copied. All directories in the path name must exist.
When copying to a save file, the save file will be created if it does not exist.
When copying to a database file member, the database file must exist. If the member does not exist, it is created. The file may be either a source physical file or a program-described physical file. Source physical files with multiple data fields are not supported.
If the database file is a source physical file, a sequence number and a date stamp of zeros is added to each record as it is copied to the database file member.
For more information on specifying path names, refer to "Object naming rules" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Top |
Specifies whether the copy operation replaces, adds, or fails to copy the records if the object specified on the To file member or save file (TOMBR) parameter already exists. If the object does not exist, it is created.
Top |
Specifies the process for converting the data from the stream file to the database file member.
This parameter is ignored when copying to a save file.
Top |
Specifies the method of obtaining the stream file code page.
This parameter is ignored when copying to a save file.
For example, if the code page associated with the stream file is 37, the stream file data is instead assumed to be in code page 1252 for data conversion.
Top |
Specifies the method of obtaining the database file CCSID.
This parameter is ignored when copying to a save file.
Top |
Specifies the path name of the conversion table to be used to convert data from the stream file to the database file member.
For more information on specifying path names, refer to "Object naming rules" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Note: This parameter is required and valid only if CVTDTA(*TBL) is specified. This parameter is ignored when copying to a save file.
Top |
Specifies the end-of-line characters which are recognized in the stream file during copying of records.
This parameter is ignored when copying to a save file.
All records are transformed to a fixed-length format as they are copied to the database file. The fixed-length is equal to the length of the database file records to which they are copied. If one of the end-of-line character options is selected (ENDLINFMT(*FIXED) is not specified) the stream file is read up to first occurrence of that character. The end-of-line character is stripped from the record. The remainder of the record is padded with blanks. The data is converted to the destination data format (if specified) and copied to the database file member. If a record is too long to fit in the fixed-length format, it is truncated, then copied.
Only stream files and database files with compatible encoding schemes, which do not result in the expansion of data record lengths, are valid with this option. If an incompatible encoding scheme combination is detected, the operation will fail.
The following encoding scheme combinations are supported:
Top |
Specifies whether embedded tab characters are expanded to blanks up to the next eight-character tab position.
This parameter is ignored when copying to a save file.
Note: If ENDLINFMT(*FIXED) is specified, *YES is not a valid value for this parameter.
Top |
Example 1: Copying Data from a Stream File to a Database File Using Automatic Conversion
CPYFRMSTMF FROMSTMF('STMF.TXT') TOMBR('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYMBR.MBR')
This command copies the data contained in stream file STMF.TXT in the current working directory to database file member /QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYMBR.MBR. Automatic conversion of data takes place using the stream file data code page and the database file CCSID. Any single-byte or double-byte character combination of CR and LF will be recognized as the end of a line in the stream file, and any embedded tabs are expanded with blanks out to the next tab position since these are the default values. If member MYMBR.MBR does not exist in the file, it is created. If member MYMBR.MBR exists, no records are copied since MBROPT(*NONE) is the default value.
Example 2: Copying Data from a Stream File to a Database File Using a Conversion Table
CPYFRMSTMF FROMSTMF('FINANCE.NEW') TOMBR('/QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR') CVTDTA(*TBL) STMFCODPAG(437) TBL('/QSYS.LIB/QUSRSYS.LIB/TBL1.TBL') ENDLINFMT(*CRLF) TABEXPN(*NO)
This command copies the data in stream file FINANCE.NEW in the current working directory to the database file member /QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR. The data in the stream file is converted using the user-specified conversion table TBL1.TBL contained in the directory /QSYS.LIB/QUSRSYS.LIB. The double character combination of CR and LF is recognized as the end of a stream file line. Any embedded tabs are not expanded with blanks. The line-formatting characters are recognized from code page 437 specified on the STMFCODPAG parameter.
Example 3: Copying Data from a Stream File to a Data-base File Without Data Conversion
CPYFRMSTMF FROMSTMF('FINANCE.NEW') TOMBR('/QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR') CVTDTA(*NONE) ENDLINFMT(*FIXED)
This command copies the data in stream file 'FINANCE.NEW' in the current working directory to the database file member /QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR without data conversion. The stream file data lines are considered to be fixed length records of the same length as the database file records. Because TABEXPN(*NO) is specified, any tab characters encountered are not expanded to blanks during copying. If the encoding scheme of the stream file and the database file differ, the copy ends with an error message.
Example 4: Copying Data from a Stream File to a Save File
CPYFRMSTMF FROMSTMF('/MYDIR/SOFTWARE') TOMBR('/QSYS.LIB/PACKAGE.LIB/SOFTWARE.FILE')
This command copies the data contained in stream file /MYDIR/SOFTWARE to the save file /QSYS.LIB/PACKAGE.LIB/SOFTWARE.FILE. The stream file data is copied as fixed-length records with length of 528. No line-formatting characters are inserted, nor is any data conversion performed.
Top |
*ESCAPE Messages
Top |