CL Programming

Moving an Object from a Test Library to a Production Library (Programmer)

PGM PARM(&OBJ &OBJTYPE &OPER)
DCL &OBJ *CHAR LEN(10)
DCL &OBJTYPE *CHAR LEN(7)
DCL &OPER *CHAR LEN(1)  /* R=Replace M=Move */
IF ((&OPER *NE 'M') *AND (&OPER *NE 'R')) THEN(DO)
        SNDPGMMSG MSG('Operation code must be "R" or "M" ')
        RETURN
        ENDDO
IF ((&OBJTYPE *NE *PGM) *AND (&OBJTYPE *NE *FILE) *AND (&OBJTYPE +
    *NE *DTAARA)) THEN(DO)
        SNDPGMMSG MSG('Object' *BCAT &OBJ *BCAT ' must be *PGM, +
                  *FILE, or *DTAARA')
        RETURN
        ENDDO
CHKOBJ BLDLIB/&OBJ OBJTYPE(&OBJTYPE)
MONMSG MSGID(CPF9801) EXEC(DO)
        SNDPGMMSG MSG('Object or object type does not exist +
                  in BLDLIB')
        RETURN
        ENDDO
IF (&OPER *EQ 'M') THEN(DO)
        MOVOBJ BLDLIB/&OBJ OBJTYPE(&OBJTYPE) TOLIB(PRODLIB)
        MONMSG MSGID(CPF3208) EXEC(DO)
                        SNDPGMMSG MSG('Object' *BCAT &OBJ *BCAT ' +
                                  already exists in PRODLIB')
                        RETURN
                        ENDDO
        CHKOBJ PRODLIB/&OBJ OBJTYPE(&OBJTYPE)
        MONMSG MSGID(CPF9801) EXEC(DO)
        SNDPGMMSG MSG('Object or object type does not +
                  exist in PRODLIB')
                  RETURN
                  ENDDO
        ENDDO
RETURN
ENDPGM

The object name, object type, and operation code are passed from another program or procedure. Checks are performed to see that the operation code and object type are correct, and that the object exists in the test library. The object is moved unless it already exists in the production library. The move is then confirmed. More commands can be added to grant additional authority to the object or to handle additional exceptions and additional object types.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]