CL Command Reference - CPYFRMSTMF
CL Command List > CPYFRMSTMF Reference
Description:
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.
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:
1. The database-member-path-name must be of the form name.object-type. For example, /QSYS.LIB/LIBA.LIB/FILEA.FILE/MBRA.MBR is the form required by the QSYS.LIB file system.
2. The save-file-path-name must be of the form name.object-type. For example, /QSYS.LIB/LIBA.LIB/SAVEFILEA.FILE is the form required by the QSYS.LIB file system.
3. The following authorities are required: v Execute (*X) authority to directories in the path name prefix of the database file, save file, stream file or conversion table.
. Read (*R) authority to the stream file.
. One of the following authorities to the database file:
¨C *X and add (*ADD) to do MBROPT(*ADD)
¨C *X, object management (*OBJMGT), *ADD, and delete (*DLT) to do MBROPT(*REPLACE)
. If a new member is created in the database file, the following authorities are required:
¨C *X, *OBJMGT, and *ADD to the database file.
¨C *X and *ADD to the directory containing the database file.
. Read, execute (*RX), *OBJMGT, and *ADD to the save file if the save file already exists.
. *RX and *ADD to the save file¡¯s parent directory if the save file does not already exist.
. If a conversion table was specified, object operational (*OBJOPR) to the conversion table.
Examples:
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.