Moving objects from one library to another

The Move Object (MOVOBJ) command moves objects between libraries.

Moving objects from one library to another is useful in that you make an object temporarily unavailable and it lets you replace an out-of-date version of an object with a new version. For example, a new primary file can be created to be temporarily placed in a library other than the one containing the old primary file. Because the data in the old primary file is normally copied to the new primary file, the old primary file cannot be deleted until the new primary file has been created. Then, the old primary file can be deleted and the new primary file can be moved to the library that contained the old primary file.

You can only move an object if you have object management authority for the object, delete and execute authority for the library the object is being moved from, and add and read authority to the library the object is being moved to.

You can move an object out of the temporary library, QTEMP, but you cannot move an object into QTEMP. Also, you cannot move an output queue unless it is empty.

Moving journals and journal receivers is limited to moving these object types back into the library in which they were originally created. If the journal objects have been placed into QRCL by a Reclaim Storage (RCLSTG) command, they must be moved back into their original library to be made operational.

The following is a list of objects that cannot be moved:

  • Authorization lists (*AUTL)
  • Class-of-service descriptions (*COSD)
  • Cluster resource group (*CRG)
  • Configuration lists (*CFGL)
  • Connection lists (*CNNL)
  • Controller descriptions (*CTLD)
  • Data dictionaries (*DTADCT)
  • Device descriptions (*DEVD)
  • Display station message queues (*MSGQ)
  • Documents (*DOC)
  • Edit descriptions (*EDTD)
  • Exit registration (*EXITRG)
  • Folders (*FLR)
  • Double-Byte Character Set (DBCS) font tables (*IGCTBL)
  • Image catalog (*IMGCLG)
  • Internet Packet Exchange Description (*IPXD)
  • Job schedules (*JOBSCD)
  • Libraries (*LIB)
  • Line descriptions (*LIND)
  • Mode descriptions (*MODD)
  • NetBIOS description (*NTBD)
  • Network interface descriptions (*NWID)
  • Network Server Configuration (*NWSCFG)
  • Structured Query Language (SQL) packages (*SQLPKG)
  • Start of changeStructured Query Language (SQL) XML schema repository (*SQLXSR)End of change
  • System/36 machine descriptions (*S36)
  • The system history log (QHST)
  • The system operator message queue (QSYSOPR)
  • Time zone description (*TIMZON)
  • User-defined SQL type (*SQLUDT)
  • User profiles (*USRPRF)

In the following example, a file from QGPL (where it was placed when it was created) is moved to the order entry library DISTLIB so that it is grouped with other order entry files.

Example of moving objects from one library to another

To move the object, you must specify the to-library (TOLIB) as well as the object type (OBJTYPE):

MOVOBJ  OBJ(QGPL/ORDFILL)  OBJTYPE(*FILE)  TOLIB(DISTLIB)

When you move objects, you should be careful not to move objects that other objects depend on. For example, CL procedures may depend on the command definitions of the commands used in the procedure to be in the same library at run time as they were at module creation time. At compile time and at run time, the command definitions are found either in the specified library or in a library in the library list if *LIBL is specified. If a library name is specified, the command definitions must be in the same library at run time as they were at compile time. If *LIBL is specified, the command definitions can be moved between compile time and program run time as long as they are moved to a library in the library list. Similarly, any application program you write can depend on certain objects being in specific libraries.

An object referring to another object may be dependent on the location of that object (even though *LIBL can be specified for the location of the object). Therefore, if you move an object, you should change any references to it in other objects. The following lists examples of objects that refer to other objects:

  • Subsystem descriptions refer to job queues, classes, message queues, and programs.
  • Command definitions refer to programs, message files, help panel groups, and source files that are containing REXX procedures.
  • Device files refer to output queues.
  • Device descriptions refer to translation tables.
  • Job descriptions refer to job queues and output queues.
  • Database files refer to other database files.
  • Logical files refer to physical files or format selections.
  • User profiles refer to programs, menus, job descriptions, message queues, and output queues.
  • CL programs refer to display files, data areas, and other programs.
  • Display files refer to database files.
  • Printer files refer to output queues.
Note: You should be careful when moving objects from the system library QSYS. These objects are necessary for the system to perform effectively and the system must be able to find the objects. This is also true for some of the objects in the general-purpose library QGPL, particularly for job and output queues.

The Move Object (MOVOBJ) command moves only one object at a time.