Copy

PURPOSE:  The COPY command creates a copy of a specified Data Set, Schema Definition, Command Module, Process Module, Global Storage definition, System File, Data Index definition, Index Definitions, or Find Subset.  Copies can be made within a DBL or across DBL’s.  The command creates a duplicate of the object specified or just the object’s text to a System File.

SYNTAX

COPY {CF; CM; CS; DI; DS; FS; GS; ID; PM; SD; SI; SF} source_name [IN DBL dbl_name] TO {destination_name; SF name}

CF

is a Control File.

CM

is a Command Module.

CS

is a Code Segment.

DI

is a Data Index.  The associated index is formed the first time it is declared and used.

DS

is a Data Set.

FS

is a Find Subset.  Any Find Subset can be copied, whether it is cataloged in a DBL or not.

GS

is a Global Storage.

ID

is an Index Definition.

PM

is a Process Module.

SD

is a Schema Definition.

SF

is a System File.  Any System File can be used, whether it is cataloged in a DBL or not.

SI

is a System Information object.

source_name

is the name of the object to be copied.

[IN DBL dbl_name]

may be used to specify an object not in the current DBL.

TO

is a required key word when using the COPY command.

destination_name

is the name of the destination object.  The IN DBL clause may be used to specify a destination object not in the current DBL.

SF name

specifies the System File which will receive the selected object's text.  Since this option copies only the text of an object, it cannot be used when that text has been removed.

EXAMPLE

COPY may be used with the CONVERT command to modify a Schema Definition that is already associated with a Data Set.  In the following example, a Data Set named BOOKS_DBM2 is modified by first copying its Schema Definition BOOKS_DBM2 to another Schema Definition BOOKS2 which is not yet associated with a Data Set and can therefore be changed.  After the new SD BOOKS2 is modified, a new Data Set BOOKS2 is created whose records will be described by the new Schema Definition.  The data is then converted from the original Data Set to the new Data Set, the original Data Set and Schema Definition are deleted, and the new Data Set and Schema Definition are assigned the original names.

*COPY SD BOOKS_DBM2 TO BOOKS2
*MODIFY SD BOOKS2
--PRINT
00010  TITLE_CODE,CHAR,6
00020  TITLE_TEXT,CHAR,40
00030  TYPE_CODE,CHAR,12
00040  PUB_CODE,CHAR,4
00050  PRICE,FLOAT,10,2
00060  ADVANCE_AMT,FLOAT,10,2
00070  ROYALTY,FLOAT,3
00080  YTD_SALES,FLOAT,10,2
--INSERT 90
00090  NOTES,CHAR,200
00100  PUB_DATE, FULLDATE
00110  END
--SAVE
*CREATE DS BOOKS_2 SD BOOKS2
*USE DS BOOKS_DBM2
*CONVERT TO BOOKS_2
*REMOVE DS BOOKS_DBM2
*REMOVE SD BOOKS_DBM2
*RENAME SD BOOKS2 AS BOOKS_DBM2
*RENAME DS BOOKS2 AS BOOKS_DBM2

The following examples copy an object's text to a System File:

*COPY SD AUTHORS_DBM2 TO SF WRITERS
*COPY PM QUICK_REP IN DBL BOOKS TO SF Q_REP2

NOTES:  The COPY command will not copy over an existing object.  Data Sets are an exception, and the rules regarding them are given below.  Thus the COPY command is not allowed if a like object having the specified destination name already exists in the destination DBL.

Data Sets can be copied to existing Data Sets if the source Data Set has the same Schema Definition as the existing Data Set that it will overwrite.

When copying Data Sets across DBL’s, the destination Data Set must already exist in the destination DBL.  If a Data Set is cataloged in more than one DBL, keep in mind that the information about its use is recorded only in the DBL through which it is currently accessed.

If the text for an SD, CM, PM, GS, or DI has been removed, the COPY command cannot be used on it; i.e., it is not possible to copy compiled code without the corresponding text.

For Process Modules and Data Index definitions, only the text, not the compiled code, is copied across DBL’s.  Therefore, before they can be executed, copied PM’s and DI’s must be compiled by issuing the MODIFY command and the SAVE editing command.  This step ensures that Process Modules and Data Index definitions reference Schema Definitions, Data Sets, and Global Storage definitions that exist in the destination DBL.

For System Files and Find Subsets, if the source object is cataloged, a DBL entry is also made in the destination DBL.  Otherwise, just the System File is copied.  For all other object types, an entry is created in the destination DBL.  Creation date and time are transferred to the destination object’s DBL entry.  For Data Sets, the total record count, deleted count, and current update numbers are transferred.

When copying an ACCENT R DBL object (such as a Schema Definition, Data Index, Command Module, or Process Module) to a System File, the line numbers are not copied.  The System File created is a sequential variable length file readable by most editors.