Command reference / ifs
CPYTOSTMF
Copy To Stream File
Copies a database file member or save file to a stream file. A database member copy can convert the encoding and add line-ending characters.
Allowed environments: *ALL.
Positional parameters: 2.
Parameters
FROMMBR
From file member or save file
Sets the path name of the database file member or save file from which data is copied. When copying from a member, the file may be a source physical file or a program-described physical file. Source physical files with multiple data fields are not supported.
TOSTMF
To stream file
Sets the path name of the stream file to which data is copied. All directories in the path name must exist. New directories are not created. If the stream file does not exist, it is created.
STMFOPT
Stream file option
Controls whether the copy operation replaces, adds, or fails to copy the records in a stream file if a stream file with the specified name already exists. If the stream file does not exist, it is created.
Allowed values:
*NONE, *ADD, *REPLACE
*NONE- No records are copied and the operation will fail.
*ADD- The records are added to the end of the existing stream file records. This value is not allowed when copying a save file.
*REPLACE- The records replace the existing stream file records.
CVTDTA
Data conversion options
Sets the process for converting the data from the database file member to the stream file. This parameter is ignored when copying a save file.
Allowed values:
*AUTO, *TBL, *NONE
*AUTO- The data is converted during the copy operation using the coded character set identifier (CCSID) of the stream file and the database file CCSID.
*TBL- The data is converted using a conversion table. Only single-byte character sets are supported. The conversion table must be specified by the Conversion table (TBL) parameter. If a conversion table is not available, the operation will fail.
*NONE- Only the removal of the sequence numbers and date stamp from source physical files and the optional insertion of specified line-formatting characters into the stream file are performed.
DBFCCSID
Database file CCSID
Sets the method of obtaining the database file CCSID. This parameter is ignored when copying a save file.
Suggested / special values:
*FILE
*FILE- The database file CCSID is used, unless it is 65535. If the database file CCSID is 65535, and the file is not a program-described file, the operation will fail.
1-65533- Enter the database file coded character set identifier (CCSID).
STMFCCSID
Stream file CCSID
Sets the method of obtaining the stream file coded character set identifier (CCSID) used for data conversion. This parameter is ignored when copying a save file.
Suggested / special values:
*STMF, *PCASCII, *STDASCII
*STMF- If the stream file exists, and data conversion is requested, the CCSID associated with the stream file is used to perform the conversion.
*STDASCII- A CCSID in the IBM PC Data encoding scheme (x2100) is computed. If the stream file exists, and the stream file CCSID is not the same as the computed value, the operation will fail.
*PCASCII- A CCSID in the Microsoft Windows encoding scheme (x4105) is computed. ("Microsoft" and "Windows" are registered trademarks of Microsoft Corporation).
1-65533- Enter the CCSID used. If the stream file exists, this option is only valid if the CCSID associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
TBL
Conversion table
Sets the path name of the conversion table used to convert data from the database file member to the stream file. Note: This parameter is required and valid only if CVTDTA(*TBL) is specified. This parameter is ignored when copying a save file.
ENDLINFMT
End of line characters
Sets the end-of-line characters to insert into the stream file during the copying of records. This parameter is ignored when copying a save file.
Allowed values:
*CRLF, *LF, *CR, *LFCR, *FIXED
*CRLF- Carriage-return followed by line-feed is appended to the end of each line.
*LF- Line-feed is appended to the end of each line.
*CR- Carriage-return is appended to the end of each line.
*LFCR- Line-feed followed by carriage-return is appended to the end of each line.
*FIXED- The lines in the stream file are written as fixed length records. CR and LF characters are not added at the end of each line, trailing blanks are not removed from the end of each record.
AUT
Authority
Sets the method used to assign authority information to the stream file. This parameter is ignored if the stream file already exists.
Allowed values:
*DFT, *INDIR, *FILE, *INDIRFILE
*DFT- The owner of the stream file will be granted *RWX data authority to the stream file. The primary group and *PUBLIC will have *NONE data authority to the stream file.
*INDIR- The authority information for the stream file is based on the authority for the directory where the stream file is to be created.
*FILE- The authority information for the stream file is based on the authority for the object specified on the From file member or save file (FROMMBR) parameter.
*INDIRFILE- The authority information for copied objects is initially based on the authority for the directory where the objects are to be created.
STMFCODPAG
Stream file code page
Sets a code page value to be used when determining the stream file coded character set identifier (CCSID). This parameter is ignored when copying a save file.
Suggested / special values:
*STMF, *PCASCII, *STDASCII
*STMF- If this value is specified, no code page processing is performed.
*STDASCII- A CCSID in the IBM PC Data encoding scheme (x2100) is computed. If the stream file exists, and the stream file CCSID is not the same as the computed value, the operation will fail.
*PCASCII- A CCSID in the Microsoft Windows encoding scheme (x4105) is computed. ("Microsoft" and "Windows" are registered trademarks of Microsoft Corporation).
1-32767- Enter the code page used. A CCSID is computed from this value. If the stream file exists, this option is only valid if the CCSID associated with the stream file is the same as the computed value. Otherwise, the operation will fail.
Examples
CPYTOSTMF FROMMBR('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYMBR.MBR') TOSTMF('STMF.TXT')
Copies the data contained in database file member /QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYMBR.MBR to a stream file named STMF.TXT in the current working directory.
CPYTOSTMF FROMMBR('/QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR') TOSTMF('/MYDIR/FINANCE.MNG') CVTDTA(*TBL) DBFCCSID(37) STMFCCSID(437) TBL('/QSYS.LIB/QUSRSYS.LIB/TBL1.TBL') ENDLINFMT(*CRLF)
Copies the data contained in database file member /QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR to a stream file named FINANCE.MNG in the user directory /MYDIR.
CPYTOSTMF FROMMBR('/QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR') TOSTMF('/MYDIR/FINANCE.MNG') CVTDTA(*NONE) ENDLINFMT(*FIXED)
Copies the data contained in database file member /QSYS.LIB/FINANCE.LIB/STAFF.FILE/MNGR.MBR to the stream file FINANCE.MNG in the user directory MYDIR without data conversion.
CPYTOSTMF FROMMBR('/QSYS.LIB/PACKAGE.LIB/SOFTWARE.FILE') TOSTMF('/MYDIR/SOFTWARE')
Copies the data contained in save file /QSYS.LIB/PACKAGE.LIB/SOFTWARE.FILE to the stream file /MYDIR/SOFTWARE.
CPYTOSTMF FROMMBR('/QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYMBR.MBR') TOSTMF('STMF.TXT') AUT(*FILE)
Performs the same processing as the first example.
Generated from os/cl/catalog/CPYTOSTMF.json and os/cl/help/CPYTOSTMF.json.