Midrange News for the IBM i Community

Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
How to use Generic CHGOWN Change Object Owner
has no ratings.
Published: 19 Feb 2014
Revised: 20 Feb 2014 - 1756 days ago
Last viewed on: 12 Dec 2018 (5458 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

How to use Generic CHGOWN Change Object Owner Published by: Bob Cozzi on 19 Feb 2014 view comments(2)

For most people a single-object CHGOBJOWN CL command provides everything they need. When a more granular and potentially generic situation comes up, incorporating PDM WKROBJPDM into your workflow along with a User Defined Option that issues CHGOBJOWN, can provide simple results.

However, in some cases, such as software distribution to another partition or physical box, it's often more productive to use the CHGOWN command instead of CHGOBJOWN. CHGOWN is included on all systems and supports both IFS and QSYS objects. But object names need to be specified in the IFS file system syntax.

I use it all the time. With the possible exception of remembering to include the Revoke Current Owners Authority parameter, it is my command of choice for changing the owner for a group of objects.

CHGOWN OBJ('/qsys.lib/xxxxxx.lib/*') NEWOWN(QPGMR) RVKOLDAUT(*NO) 

In the above example, I'm changing all the objects in the library named XXXXXX to owner QPGMR and I am NOT revoking authority to the user profile that currently owns the objects.

You can include a suffix on the OBJ parameter that isolates the command to specific types of objects, for example to change the owner of all the Programs in library PAYROLL, the following command could be used:

CHGOWN OBJ('/qsys.lib/payroll.lib/*.pgm') NEWOWN(QPGMR) RVKOLDAUT(*NO) 

Note the addition of the .pgm suffix on the OBJ parameter. This forces the command to use only *PGM objects. Many object types are supported, as well as "no suffix" meaning *ALL object types.

The generic capabilities is even better when you use a prefix on the object name. For example, to change all the objects in library APLIB that begin with the letters "GL", the following commad could be used:

CHGOWN OBJ('/qsys.lib/apilib.lib/GL*.pgm') NEWOWN(QPGMR) RVKOLDAUT(*NO) 

Give it a try, it's simple.



Return to midrangenews.com home page.
Sort Ascend | Descend