CHANGING A LIBRARY’S OWNER and ALL of its OBJECTS

Bill Hoagland

Many times libraries have been created and later realized it has the wrong owner, or you decide to use a new authority scheme in your company and want to change the owner and authority.  It takes a long time to change all the effected objects and the library owner. I created a simple utility command to do the work for you. It only requires 1 CL PGM, 1 CMD and 1 file. In short the CL command will build a file of all the objects in a library and then change the owner of all the objects to the new owner you want them to be. You even have an option to save or revoke the authority of the old owner too.

Just compile the CL Program, Command, and create the File below all in your favorite Utility library, or personal library and give it a try

CL PROGRAM

PGM        PARM(&LIB &NEWOWNER &CURAUT) 
DCLF       FILE(YOURLIB/OBJOWN)
DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)
DCL        VAR(&CURAUT) TYPE(*CHAR) LEN(10)
DCL        VAR(&NEWOWNER) TYPE(*CHAR) LEN(10)
DSPOBJD    OBJ(&LIB/*ALL) OBJTYPE(*ALL) +
         OUTPUT(*OUTFILE) OUTFILE(YOURLIB/OBJOWN)
RCVF:       RCVF       DEV(*FILE)
MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
CHGOBJOWN  OBJ(&ODLBNM/&ODOBNM) OBJTYPE(&ODOBTP) +
      NEWOWN(&NEWOWNER) CUROWNAUT(&CURAUT)
MONMSG     MSGID(CPF0000)
GOTO       CMDLBL(RCVF)                               
END:        ENDPGM

COMMAND

CMD        PROMPT(‘Change Library Owner’)
PARM       KWD(LIB) TYPE(*CHAR) LEN(10) MIN(1) +
     PROMPT(‘Library’) 
PARM       KWD(NEWOWN) TYPE(*CHAR) LEN(10) MIN(1) +
     PROMPT(‘New Owner’)
PARM       KWD(CURAUT) TYPE(*CHAR) LEN(10) RSTD(*YES) +
     VALUES(‘*SAME’ ‘*REVOKE’) MIN(1)  PROMPT(‘Current Owner Authority’)

FILE

DSPOBJD    OBJ(YOURLIB/*ALL) OBJTYPE(*ALL) +
         OUTPUT(*OUTFILE) OUTFILE(YOURLIB/OBJOWN)

Just run this command manually one time and you will have your file created.

Leave a Reply