COBOL Manual for TNS and TNS/R Programs

Tape Input and Output
HP COBOL Manual for TNS and TNS/R Programs522555-006
27-4
Unlabeled Tape Files
Topics:
How to read or write One File on One Tape
How to read or write Several Files on One Tape
How to read or write One File on Several Tapes
Mount Messages
One File on One Tape
To read or write one file on one tape, follow Step 1 through Step 5 under Unlabeled
Tape Files and then execute this step:
Close the file with the CLOSE statement. Do not use a NO REWIND phrase. Use a
LOCK phrase if the file was not dynamically assigned and you want to prevent the
tape from being reopened (the run-time tape routine ignores LOCK for a
dynamically assigned file).
Example 27-1 assigns the COBOL file name TAPE1 to the system file name $DRIVE2
(a name that the system administrator assigned to a tape drive) and declares its
organization and access modes to be sequential; then it opens TAPE1 for exclusive
input, reads, closes, and locks it.
Example 27-1. One File on One Tape
...
ENVIRONMENT DIVISION.
...
INPUT-OUTPUT SECTION.
...
FILE-CONTROL
SELECT TAPE1 ASSIGN $DRIVE2
ORGANIZATION SEQUENTIAL
ACCESS MODE SEQUENTIAL.
...
PROCEDURE DIVISION.
...
OPEN INPUT TAPE1 EXCLUSIVE
READ TAPE1 . .
CLOSE TAPE1 LOCK
...