CL Command Reference - CRTDUPOBJ
CL Command List > CRTDUPOBJ Reference
Description:
The Create Duplicate Object (CRTDUPOBJ) command copies a single object or a group of objects. It does not create an exact duplicate of files. The newly-created object must be renamed if it is stored in the same library as the original object. If it is stored in a library other than the one that contains the original object, it can retain the name of the original object. You can copy a group of related objects by specifying a generic object name and the library in which the newly-created objects are stored. You can also specify whether data in physical files or save files is copied.
Note: The value of the Create authority (CRTAUT) parameter specified on the Create Library (CRTLIB) command for the to-library is not used for the duplicate object. The public and private authorities for the duplicate object will be the same as the original object. The owner of the duplicate object is either the user profile of the user who issues the command or the group profile if the user profile of the user who issues the command is a member user profile that has specified that the group should be the owner.
When duplicating a file using the CRTDUPOBJ command, the format of the existing file specified for the From object (OBJ) parameter is shared with the newly-created file specified for the New object (NEWOBJ) parameter. When the maximum number (approximately 32K) of file objects that share the same format has been reached, the newly-created file will create a new format instead of sharing the FROM file¡¯s format.
Note: All of the files that share the same format will be considered related and will be grouped together in the same save list when a save operation is performed.
When a logical file is copied into another library, two cases determine the basing for the file:
1. If both the logical file and its based-on physical file are originally in the same library, a duplicate of the physical file must be created in the new library before a duplicate of the logical file is created. After these two duplicates are created, the new logical file is based on the new physical file.
2. If the logical file and its based-on physical file are originally in different libraries, it is not necessary to duplicate the physical file before duplicating the logical file. In this case, the duplicated logical file is based on the same physical file as was the original logical file. Unlike the first case, even if the physical file is copied into the new library before the logical file is copied, the duplicated logical file is based on the original physical file, not on the duplicated physical file.
When the CRTDUPOBJ command creates a data base physical file, you can use the Duplicate constraints (CST) parameter to specify whether or not any constraints associated with the existing file are to be associated with the newly-created file. Similarly, you can use the Duplicate triggers (TRG) parameter to specify whether or not any triggers associated with the existing file are to be associated with the newly-created file. Note that there are special considerations of which to be aware relating to the duplication of triggers. For example, the duplication will differ depending on whether or not the trigger program associated with the existing file was in the same library as the existing file.
When the object type of the object to be duplicated is an object type which can be journaled, the existence and content of a data area named QDFTJRN in the to-library will determine whether or not journaling is started for the newly-created object.
Restrictions:
1. You must have use (*USE) and object management (*OBJMGT) authorities for the existing object.
2. You must have use (*USE) and add (*ADD) authorities for the library for the new object.
3. You must have authorization list management (*AUTLMGT) authority if the object is an authorization list.
4. You must have object operational (*OBJOPR) authority for the Create Save File (CRTSAVF) command to create a duplicate save file. The contents of the save file are duplicated when *YES is specified for the Duplicate data (DATA) parameter.
5. When an object is to be duplicated, it is created in the same auxiliary storage pool (ASP) as the to-library.
6. If *YES is specified for the Duplicate data (DATA) parameter when the CRTDUPOBJ command is used to create a copy of a file, the new duplicate file object is seized (similar to an *EXCL lock with no timeout) for the duration of the data copy making access impossible. An attempt to use a function that refers to the new duplicate file object while the data copy is in progress results in a lock up for that work station until the data copy is completed. The following are examples of functions that should not be used on the new duplicate file object until the data copy is completed:
. WRKACTJOB (Option 11-Locks; Option 8-WRKOBJLCK)
. DSPDBR
. DSPFD
. DSPFFD
. DSPJOB (Option 12-Locks; F10-Job record locks; Option 14-Open files)
. DSPLIB (The library containing the new duplicate file)
. DSPOBJD
. WRKOBJLCK
. DSPRCDLCK
. Any other function which refers to the new duplicate file
7. When duplicating a database file or a save file and storage for the from-library is allocated from a primary or secondary auxiliary storage pool (ASP), storage for the to-library must either be allocated from an ASP in the same ASP group as the storage for the from-library or be allocated from the system ASP (ASP 1) or a basic user ASP (ASPs 2-32). Duplicating a database file or a save file from one ASP group to another ASP group is not supported.
8. When creating a duplicate object of type *GSS, *FNTRSC, *FORMDF, *OVL, *CSI, *PAGDFN, or *PAGSEG, the name of the new object cannot exceed 8 characters in length.
9. The user space (*USRSPC) and user index (*USRIDX) user domain objects can be copied only into libraries that are permitted in the system value QALWUSRDMN (allow user domain objects in library). However, if the user object was created as a system domain object, it is not restricted.
Examples:
Example 1: Duplicating a File Including the Data Records, Constraints, and Triggers
CRTDUPOBJ OBJ(FILEA) FROMLIB(LIB1) OBJTYPE(*FILE)
TOLIB(LIB2) DATA(*YES)
The file named FILEA in library LIB1 is duplicated and stored in library LIB2. Authorities granted for FILEA are granted to the new FILEA in LIB2. The data records, constraints, and triggers associated with FILEA in library LIB1 are copied to FILEA in LIB2.
Example 2: Duplicating a File Without the Data Records, Constraints, and Triggers
CRTDUPOBJ OBJ(FILEB) FROMLIB(LIB3) OBJTYPE(*FILE)
NEWOBJ(FILEDUP) DATA(*NO) CST(*NO) TRG(*NO)
The file named FILEB in library LIB3 is duplicated in library LIB3 as FILEDUP. Authorities granted for FILEB are granted to the new FILEDUP in LIB3. The data records, constraints, and triggers associated with FILEB in library LIB3 are not copied to FILEDUP in LIB3.