Ask the Expert

Changing objects owned by one user to another

Is there a way to do a mass change object owner to a new object owner?

If your intent is to change objects owned by one particular user to another, you could use the WRKOBJOWN command to get a list of objects for a user. You could then change them all using Option 9...



    Work with Objects by Owner


User profile . . . . . . . :   KGRAAP


Type options, press Enter.

  2=Edit authority        4=Delete   5=Display authority   7=Rename

  8=Display description   9=Change owner


Opt  Object                Library       Type      Attribute

 9   KGRAAP                QSYS          *LIB      TEST

 9   KGRAAP                QUSRSYS       *MSGQ

Parameters or command


F3=Exit      F4=Prompt   F5=Refresh   F9=Retrieve   F11=Display descriptions

F12=Cancel   F17=Top     F18=Bottom   F22=Display entire name  

Using Option 9 will execute a separate CHGOBJOWN command for each object selected.

As you have already discovered, the CHGOBJOWN command is designed to change only one object at a time. Not very useful when you want to change a whole bunch of objects owned by many different user profiles!

However, the DSPOBJD command supports generic names and can also direct it output to a DB file for processing in a program.

A simple CLP can be created to list a group of objects to a DB file, and then read this list to execute the CHGOBJOWN command over and over again...

Here is an example of such a program, without any bells and whistles or error checking....

Before using this program you would want to modify the DSPOBJD command so it selects the objects you want to change. Remember, you can use a generic name, since the DSPOBJD supports this.

       DCL        VAR(&NEWOWN) TYPE(*CHAR) LEN(10)
       DCL        VAR(&CUROWNAUT) TYPE(*CHAR) LEN(6) /* *REVOKE or *SAME */

       DCLF       FILE(QADSPOBJ)

       DSPOBJD    OBJ(mylib/myobjects) +
                  OBJTYPE(*LIB) +
                  OUTPUT(*OUTFILE) + 
                  OUTFILE(QTEMP/TEMPFILE) +
                  TOFILE(QTEMP/TEMPFILE) + 
       MONMSG     MSGID(CPF0864) +
                  EXEC(GOTO CMDLBL(END)) 
                  OBJTYPE(&ODOBTP) +  
                  NEWOWN(&NEWOWN) +
                  CUROWNAUT(&CUROWNAUT) +

       GOTO       CMDLBL(READ)

After compiling this CLP (CRTCLPGM), you would run it like this:


This will change the ownership of every object selected by the DSPOBJD command, to USER1 and *REVOKE all other private authorities.

This was first published in February 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: