CPYTODKT (Copy To Diskette)

CPYTODKT Command syntax diagram

 

Purpose

The Copy to Diskette (CPYTODKT) command copies a database or device file to a diskette file. The to-file must be a diskette file. The from-file can be a physical, logical, DDM, tape, or diskette file, or a spooled inline file.

Note: For more information on DDM files, see the Distributed Data Management topic in the Information Center.

This command offers a subset of the parameters available on the Copy File (CPYF) command, along with more specific diskette-oriented parameters. This should eliminate the need for a separate override command. If parameters are needed that are not available on the CPYTODKT command, either use overrides for the from-file or the to-file, use the CPYF command, or use a combination of file overrides with the CPYF command.

One label, a generic set, or all labels from the tape can be copied. A complete description of the combinations allowed and how to specify them is in the File Management topic in the Information Center.

Restriction: A file's open data path (ODP) cannot be shared with any other program in the job (routing step) during the copy operation.

 

Required Parameters

FROMFILE
Specifies the qualified name of the physical, logical, diskette, tape, or spooled inline file that is copied.

The name of the from-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.

from-file-name: Specify the name of the file being copied.

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

The name of the diskette 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.

diskette-file-name: Specify the name of the diskette file that receives the copied records.

 

Optional Parameters

FROMMBR
Specifies the database member names, diskette file label identifiers, or a tape file label identifier of records copied from the from-file. If the from-file is a spooled inline file, *FIRST must be specified.

*FIRST: The first member in the database file is copied. If the from-file is a tape or diskette file, the label in the device file description is used to identify the member being copied.

*ALL: All members in a database file or all data files on a diskette device file are copied. This value is not valid for a tape file or a spooled inline file.

from-member-name: Specify the name of the database file member or the label of a tape or diskette data file that is copied. If the tape label identifier contains special characters, or is greater than 10 characters in length, it must be specified on the Create Tape File (CRTTAPF), Change Tape File (CHGTAPF), or Override Tape File (OVRTAPF) command.

generic*-member-name: Specify the generic name of the member name. 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.

TOLABEL
Specifies the label identifiers of the diskette data files that receives the records copied from the from-file. The label identifier can be no longer than 8 characters.

*FROMMBR: Single or many members or label identifiers named in the FROMMBR parameter are copied into data files with the same names in the diskette to-file.

If the from-file is a nonlabeled tape file, a label identifier is created for the diskette to-file in the form of CPYnnnnn, where nnnnn is the tape sequence number of the data file.

*DKTF: The value in the diskette device file identifies the data file that receives the copied records.

data-file-identifier: Specify the label identifier of the data file on the diskette to-file that receives the records copied from the from-file.

TODEV
Specifies the name of diskette device that is used to copy records to the diskette to-file.

*DKTF: The devices specified in the diskette device file description are used.

device-name: Specify the names of the diskette device used when writing records to the diskette to-file.

TOVOL
Specifies the diskettes used when copying records to the diskette to-file.

*DKTF: The diskette volume identifiers in the diskette device file are used to identify the diskettes that receive the copied records.

*NONE: No volume identifier checking is done.

volume-identifier: Specify up to 50 volume identifiers used to identify the diskettes that receive the copied records. Each volume identifier can have up to 6 alphanumeric characters.

TOEXCHTYPE
Specifies the exchange type in which the diskette to-file is written.

*DKTF: The value specified in the diskette device file is used to determine the exchange type of the file being written.

*STD: The basic exchange format is used for a type 1 or a type 2 diskette. The H exchange type is used for a type 2D diskette.

*BASIC: The basic exchange type is used.

*H: The diskette to-file is written in H exchange format. This value is valid for type 2D diskettes initialized with 256-byte sectors.

*I: The diskette to-file is written in I exchange format. This value is valid for diskette types 1, 2, or 2D, of any valid sector size (128, 256, 512 or 1024 bytes).

TOEXPDATE
Specifies the expiration date for the diskette to-file. If a date is specified, the file is protected and is not overwritten until the day after the expiration date.

*DKTF: The expiration date specified in the diskette device file is used.

*PERM: The data file is permanently protected. An expiration date of 999999 is assigned.

file-expiration-date: Specify the date of the last day the diskette is protected. The date must be specified in the format defined by the system values QDATFMT and, if separators are used, QDATSEP. The specified date is put in the diskette label as YYMMDD.

NBRRCDS
Specifies the number of records copied to the to-file.

*END: Records are copied until the end-of-file condition is indicated.

number-of-records: Specify the number of records, ranging from 1 to 4294967288, that are copied to the to-file. Fewer records are copied if an end-of-file condition occurs before the specified number of records have been copied.

Examples for CPYTODKT

Example 1: Copying 50 Records

CPYTODKT   FROMFILE(PGMSRC)  TOFILE(QDKT)
  FROMMBR(PGMA)  TOLABEL(A)
  TOEXCHTYPE(*I)  NBRRCDS(50)

This command copies 50 records to diskette using device file QDKT. The diskette device specified on the QDKTF file description is used. Member PGMA in database source file PGMSRC is copied. Since a library qualifier is not specified, *LIBL is used to find the from-file. The records are copied to label A and are written in I exchange format.

Example 2: Copying All Members

CPYTODKT   FROMFILE(QGPL/QCLSRC)  TOFILE(QDKT)
  TODEV(DKT2)  FROMMBR(*ALL)  TOEXPDATE(*PERM)

This command copies all the members in database source file QCLSRC in the QGPL library to diskette. The diskette device file QDKT, which is defined as FILETYPE(*DATA), is used even though source records are copied to diskette. This is because source fields are always truncated when copying to a device and appended when copying back to the data base, and using a device file defined as file type *DATA is more efficient than a device file defined as *SRC. The diskette device DKT2 is used. The members are copied to like-named labels on the diskette because the default TOLABEL(*FROMMBR) is taken. The volume and file expiration date are specified on the command, thus eliminating the need for a separate override command.

Error messages for CPYTODKT

*ESCAPE Messages

CPF2816
File &1 in &2 not copied because of error.
CPF2817
Copy command ended because of error.
CPF2857
Multiple member or label copy not allowed with override.
CPF2859
Shared open data path not allowed.
CPF2864
Not authorized to file &1 in library &2.
CPF2875
Wrong file member or label opened.
CPF2904
Diskette labels not valid for multiple label copy.
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.
CPF9212
Cannot load or unload DDM file &2 in &3.