Is there a way to do a mass change object owner to a new object owner?
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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 Bottom Parameters or command ===> NEWOWN(NEWUSER) CUROWNAUT(*REVOKE) 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.
PGM PARM(&NEWOWN &CUROWNAUT) 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) + OVRDBF FILE(QADSPOBJ) + TOFILE(QTEMP/TEMPFILE) + MBR(*FIRST) READ: RCVF MONMSG MSGID(CPF0864) + EXEC(GOTO CMDLBL(END)) CHGOBJOWN OBJ(&ODLBNM/&ODOBNM) + OBJTYPE(&ODOBTP) + NEWOWN(&NEWOWN) + CUROWNAUT(&CUROWNAUT) + GOTO CMDLBL(READ) END: ENDPGM
After compiling this CLP (CRTCLPGM), you would run it like this:
CALL MYPROGRAM PARM(USER1 *REVOKE)
This will change the ownership of every object selected by the DSPOBJD command, to USER1 and *REVOKE all other private authorities.
Dig Deeper on Past Releases
Related Q&A from Ken Graap
The BRMS Network feature allows a BRMS system to connect to other BRMS systems via a network, and enables a user to consolidate media such as backup ...continue reading
The only option to correct damage preventing file journaling is to use the RCLSTG command.continue reading
Find out if log files can be omitted during a save without causing problems in a full restore.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.