CL Command Reference - CHKOBJ

CL Command List > CHKOBJ Reference

Description:

The Check Object (CHKOBJ) command checks object existence and verifies the user¡¯s authority for the object before trying to access it. If the object exists and the user has the proper authority for the object, no error messages are sent to the user. For verification, as many as ten specific authorities can be specified on the command.

These checks are particularly useful before the user tries to access several objects at the same time. This command is also used to check the validity of object names contained in CL variables and to verify object authorizations under program control.

When the command runs, the system searches for the specified object. If the object is found, the system verifies that the user is authorized to that object as specified for the Authority (AUT) parameter. If the object is not found or the user does not have the authorities specified for the AUT parameter, an error message is sent to the user.


Examples:

Example 1: Checking for Existence of a Program

CHKOBJ OBJ(LIB1/PROG1) OBJTYPE(*PGM)

This command checks for the existence of a program named PROG1 in library LIB1. Your authorities to PROG1 are not checked.



Example 2: Checking for User¡¯s Authority to File

CHKOBJ OBJ(SOURCE1) OBJTYPE(*FILE) MBR(MBR3) AUT(*CHANGE)

This command checks for the existence of file SOURCE1 and for the existence of member MBR3 in file SOURCE1. It also checks to see if you have change (*CHANGE) authority to file SOURCE1.



Example 3: Checking for Your Authority to Program

CHKOBJ OBJ(LIB1/PROG1) OBJTYPE(*PGM) AUT(*CHANGE)

This command checks the existence of program PROG1 in library LIB1. It also checks to see if you have change (*CHANGE) authority to PROG1.



Example 4: Checking User¡¯s Authority to a Logical File Member

CHKOBJ OBJ(FILEA) OBJTYPE(*FILE) MBR(MBR1) AUT(*USE)

This command checks your authority to use logical file member MBR1, and each physical file member on which MBR1 is based.



Example 5: Checking User¡¯s Add and Delete Authority

CHKOBJ OBJ(FILEA) OBJTYPE(*FILE) MBR(MBR1) AUT(*ADD *DLT)
MONMSG MSGID(CPF9802) EXEC(GOTO ERROR1)

These two commands (CHKOBJ and MONMSG) are used to verify that you have both add (*ADD) and delete (*DLT) authorities for logical file FILEA and each of the physical file members on which the logical file member MBR1 in the logical file FILEA is based. If you do not have data authority for FILEA and each of the physical file members on which FILEA is based, escape message CPF9802 is sent to the program, and control in the program is passed to the command that has the label ERROR1.