Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
How to use Generic CHGOWN Change Object Owner
has no ratings.
Published: 19 Feb 2014
Revised: 20 Feb 2014 - 3718 days ago
Last viewed on: 26 Apr 2024 (8587 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

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: How to use Generic CHGOWN Change Object Owner
Posted: 10 years 2 months 7 days 33 minutes ago

D'oh! I never thought of this. I wrote my own *CMD and CLP, years ago, that loops through an OUTFILE from DSPOBJD, doing CHGOBJOWN one object at a time. CHGOWN is, obviously, much simpler.

I do have one caution, though: If you have any *PGM objects that adopt authority, you need to be careful when changing ownership. The generic capability of CHGOWN is powerful, but there are no exclude keywords (like *OMIT in SAV command).

Posted by: Ringer
Premium member *
Comment on: How to use Generic CHGOWN Change Object Owner
Posted: 10 years 2 months 6 days 23 hours 52 minutes ago

Same thing for CHGAUT. I find sometimes that my user authority cannot do a CHGOBJOWN or GRTOBJAUT on some box but OS400 seems perfectly happy to let me do a CHGOWN or CHGAUT. 

Chris Ringer