You can use the Move Object (MOVOBJ) command to move 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:
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.
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:
The Move Object (MOVOBJ) command moves only one object at a time.