Creating duplicate objects

The Create Duplicate Object (CRTDUPOBJ) command creates 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.

Note: If you create a duplicate object of a journaled file, the duplicate object (file) will not have journaling active. However, you can select this object for journaling later. If you create a duplicate object and the object (file) has no members, the last used date field is blank and the count for number of days used is zero.

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:

  • Class-of-service descriptions (*COSD)
  • Cluster resource group (*CRG)
  • Configuration lists (*CFGL)
  • Connection lists (*CNNL)
  • Controller descriptions (*CTLD)
  • Data dictionaries (*DTADCT)
  • Device descriptions (*DEVD)
  • Data queues (*DTAQ)
  • Documents (*DOC)
  • Edit descriptions (*EDTD)
  • Exit registration (*EXITRG)
  • Folders (*FLR)
  • DBCS font tables (*IGCTBL)
  • Image catalog (*IMGCLG)
  • Internet Packet Exchange Description (*IPXD)
  • Job schedules (*JOBSCD)
  • Journals (*JRN)
  • Journal receivers (*JRNRCV)
  • Libraries (*LIB)
  • Line descriptions (*LIND)
  • Mode descriptions (*MODD)
  • Network interface descriptions (*NWID)
  • Network Server Configuration (*NWSCFG)
  • Network server descriptions (*NWSD)
  • Reference code translation tables (*RCT)
  • Server storage space (*SVRSTG)
  • Spelling aid dictionaries (*SPADCT)
  • SQL packages (*SQLPKG)
  • SQL XML schema repository (*SQLXSR)
  • System/36 machine descriptions (*S36)
  • System operator message queue (QSYSOPR)
  • System history log (QHST)
  • Time zone description (*TIMZON)
  • User-defined SQL type (*SQLUDT)
  • User profiles (*USRPRF)
  • User queues. (*USRQ)

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.