COBOL Manual for TNS/E Programs (H06.03+)

Disk Input and Output
HP COBOL Manual for TNS/E Programs520347-003
28-44
Renaming a File From an HP COBOL Program
The HP COBOL library routine COBOL_CONTROL_ is a multipurpose routine that
calls the operating system routine CONTROL, and whose function is determined by an
operation code. The operation code 20 enables a process to purge only the contents of
a file if the process has write access to the file. The process can even purge the data
from a temporary file whose name was assigned by Enscribe because you specified
only a volume name or assigned it to #TEMP.
The COBOL_CONTROL_ routine call for purging data requires two parameters. The
first parameter is the file-name described in the SELECT clause of the file-control
entry for the file; the second is the number 20 (which causes the file system to purge
the data in the file). Example:
ENTER "COBOL_CONTROL_" USING MYFILE 20
For more information about the CONTROL routine, see the Guardian Procedure Calls
Reference Manual.
Renaming a File From an HP COBOL Program
The FILE_RENAME_ procedure enables a process to rename a closed disk file,
provided the process has purge access to the file. If the file is a temporary file, the
process can call FILE_RENAME_ to make the file a permanent file. For more
information about the RENAME or FILE_RENAME_ routine, see the Guardian
Procedure Calls Reference Manual.
Creating a File Having Alternate Keys From an HP COBOL
Program
At times, it is necessary within an HP COBOL process to create and operate on a file
that has alternate keys. Suppose the file must be named and built during execution.
The only way to do this is through a series of steps involving a few Enscribe routines:
1. Declare the records of the file in a file description entry.
2. Use the FILE_CREATELIST_ procedure to create the primary file in conformance
with the specification in the file-control entry and the file description.
3. Use the FILE_CREATELIST_ procedure to create the alternate-key file in
conformance with the specification of the keys in the file-control entry and the
record description for the file.
4. Open the loadfile and use it.
Suppose you have a server process that must create a private, indexed file having one
alternate key.
Note. This explanation does not elaborate all the data definitions and all the code necessary
to manage the creation of an indexed file with an alternate key. Only the significant
declarations and code are shown. In some cases, the code mentions data items that are
presumed to have been defined and given values by statements not shown.