You can use the Create Duplicate Object (CRTDUPOBJ) command to create a copy of an existing object.
The duplicate object has the same object type and authorization as the original object and is created into the same auxiliary storage pool (ASP) as the original object. The user who issues the command owns the duplicate object.
You can duplicate an object if you have object management and use authority for the object, use and add authority for the library in which the duplicate object is to be placed, use authority for the library in which the original object exists, and add authority for the process user profile.
To duplicate an authorization list, you must have authorization list management authority for the object and both add and object operational authority for library QSYS.
Only the definitions of job queues, message queues, output queues and data queues are duplicated. Job queues and output queues cannot be duplicated into the temporary library (QTEMP). For a physical file or a save file, you can specify whether the data in the file is also to be duplicated.
The following objects cannot be duplicated:
In some cases, you may want to duplicate only some of the data in a file by following the Create Duplicate Object (CRTDUPOBJ) command with a Copy File (CPYF) command that specifies the selection values.
The following command creates a duplicate copy of the order header physical file, and duplicates the data in the file:
CRTDUPOBJ OBJ(ORDHDRP) FROMLIB(DSTPRODLIB) OBJTYPE(*FILE) + TOLIB(DISTLIB2) NEWOBJ(*SAME) DATA(*YES)
When you create a duplicate object, you should consider the consequences of creating a duplicate of an object that refers to another object. Many objects refer to other objects by name, and many of these references are qualified by a specific library name. Therefore, the duplicate object could contain a reference to an object that exists in a library different from the one in which the duplicate object resides. For all object types other than files, references to other objects are duplicated in the duplicate object. For files, the duplicate objects share the formats of the original file.
Any physical files which exist in the from-library, and on which a logical file is based, must also exist in the to-library. The record format name and record level ID of the physical files in the to- and from-libraries are compared; if the physical files do not match, the logical file is not duplicated.
If a logical file uses a format selection that exists in the from-library, it is assumed that the format selection also exists in the to-library.