CL Command Reference - ALCOBJ

CL Command List > ALCOBJ Reference

Description:

The Allocate Object (ALCOBJ) command is used in a job or thread to reserve an object or list of objects for use later in the job or thread. If an object that is needed in the job is not specified in an ALCOBJ command, an allocation is attempted automatically when the object is used.

Objects can be deallocated with the Deallocate Object (DLCOBJ) command. Allocated job-scoped locks are automatically released when the job ends. Allocated thread-scoped locks are automatically released when the thread ends. If a thread received a job-scoped lock, the job will continue to hold that lock after the requesting thread ends. Lock-space-scoped locks are not automatically released.

The DLCOBJ command should not be issued for an object that was not explicitly allocated by the ALCOBJ command. If the DLCOBJ command is used this way, internal locks on the object are released, making the object capable of being deleted.

NOTES:

1. When allocating database files, use the DLCOBJ command before deleting the file if the file being allocated is a logical file.

2. If a file is being allocated that is affected by a file override, the ALCOBJ command ignores the override and attempts to allocate the file named in the OBJ parameter.

3. When allocating distributed data management (DDM) files and distributed files, additional time is required for the command to complete because of the time required for communication and for allocating files on remote systems.

4. Work station message queues cannot be allocated. A work station message queue is associated with a work station device description of the same name. Therefore, to do an operation on a work station message queue that must be allocated, the user must allocate the associated device description. When the device description is allocated, the work station message queue is implicitly allocated.

5. When ALCOBJ is executed to get an EXCL lock on a program (*PGM), only the program object description is locked. The program code is not locked exclusively. Therefore, the program may still be run by another user. Changes are not allowed for the program object description while the actual program can still be used.

6. The system does not lock programs when calling them.

7. When ALCOBJ is executed to get an EXCL lock on a logical file member (*FILE), the lock occurs on both the logical file member and the associated physical file members. No other user can use the physical file members (not even through some other logical file member).

8. Allocating an object by specifying *LIBL for the object¡¯s library, changing the thread¡¯s library list, and then attempting to deallocate the object by specifying *LIBL for the object¡¯s library can result in issuing the deallocate against the wrong object. This could release internal locks.

Restrictions:

1. This command cannot be used to allocate a device description, *DEVD, for an advanced program-to-program communications (APPC) device or for an intrasystem (INTRA) device.

2. This command can be used to allocate only the following database *FILE types:
. Physical files
. Logical files
. Distributed files
This allocates the piece of the file on each node in the node group.

3. The object must exist on the system.

4. The user issuing the command must have object operational (*OBJOPR) authority to the object and execute (*EXECUTE) authority to the object¡¯s library.

5. If the allocation cannot be completed, none of the locks are granted, and a message is sent to the thread that issued the command. If the command is issued from a program, the Monitor Message (MONMSG) command can be used to determine whether the allocation was successful.

6. In multithreaded jobs, this command is not threadsafe for distributed files. This command is also not threadsafe for distributed data management (DDM) files of type *SNA.



Examples:

Example 1: Allocate File for Job

ALCOBJ OBJ((LIBB/FILEA *FILE *EXCL MEMBERA)) SCOPE(*JOB)
WAIT(60)

This command exclusively allocates member MEMBERA of file FILEA in library LIBB to the job in which the ALCOBJ command is used. If MEMBERA is unavailable, the job will wait 60 seconds for it to become available.


Example 2: Allocate Data Area for a Thread

ALCOBJ OBJ((LIBY/DATAAREAX *DTAARA *EXCL ))
SCOPE(*THREAD)

This command exclusively allocates data area DATAAREAX in library LIBY to the requesting thread in which the ALCOBJ command is used.


Example 3: Allocate File for Lock Space

ALCOBJ OBJ((LIBB/FILEA *FILE *EXCL MEMBERA))
SCOPE(*LCKSPC)

This command exclusively allocates member MEMBERA of file FILEA in library LIBB to the lock space attached to the current thread. If no lock space is attached, the lock is scoped to the job.