COBOL Manual for TNS and TNS/R Programs
Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs—522555-006
28-3
Locking
You can erase the contents of a file without purging the file with the FUP command
PURGEDATA. An HP COBOL program erases the contents of a file without purging the
file simply by opening the file for output. An HP COBOL program can erase the
contents of a file by calling routine COBOL_CONTROL_. The data remains on the
disk—only the current-record, next-record, and EOF pointers are reset, and the EOF
pointer in the file label on the disk are changed to indicate that the file is logically
empty.
To erase the data on the disk, you must:
1. Use either the FUP SECURE command with its CLEARONPURGE option or call
the routine COBOL_SETMODE_ to set function 52 (see the Guardian User’s
Guide).
2. After setting the CLEARONPURGE flag, call the PURGE routine (directly or
through FUP).
The CLEARONPURGE flag has no effect on the outcome of a PURGEDATA operation
performed through FUP or through the CONTROL routine.
Locking
An HP COBOL program can lock and unlock an entire file with the LOCKFILE and
UNLOCKFILE statements. Batch programs lock entire files more often than transaction
processing programs do.
An HP COBOL program can lock individual records in a file with the LOCK phrase of
the READ statement and unlock them with either the UNLOCKRECORD statement or
the REWRITE statement with UNLOCK.
You must lock files when one process needs exclusive access to a record, a set of
records, or an entire file for some logical operation to complete successfully (as in the
case of TMF). For more information, see Avoiding Deadlock).
Ownership and Security
Each disk file on the HP system has an owner and a file security. Initially, the owner is
the user who creates the file and the security is the default file security. The owner can
transfer ownership to another user with the FUP GIVE command. The owner of a file
can change the file’s security with the FUP SECURE command.
The security system recognizes a file owner by the user ID, which consists of a group
number and a user number. The operating environment obtains the group number and
user number from the group name and user name when the user logs on; for example,
if you log on as PROJECT3.SANDY, your group name is PROJECT3 and your user
name is SANDY, and the operating environment translates these names to their
corresponding group number and user number.