COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
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 262 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 262 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
...
Several Files on One Tape
To read or write more than one file on one tape, follow Step 1 through Step 5 under Unlabeled
Tape Files and then execute these steps:
1. Close the file with the CLOSE statement, specifying NO REWIND. The NO REWIND phrase
prevents the run-time routines from rewinding the tape, so that you can read or write the file
that immediately follows the file you just closed.
2. Reopen the file specifying NO REWIND (see Step 4 under Unlabeled Tape Files).
3. Read or write the file again (see Step 5 under Unlabeled Tape Files).
4. 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 263 writes two files on one tape and then closes and locks the tape.
Example 263 Several Files on One Tape
...
ENVIRONMENT DIVISION.
...
INPUT-OUTPUT SECTION.
...
FILE-CONTROL
SELECT TAPE1 ASSIGN $DRIVE2
ORGANIZATION SEQUENTIAL
ACCESS MODE SEQUENTIAL.
...
PROCEDURE DIVISION.
...
*WRITE FIRST FILE
OPEN OUTPUT TAPE1 EXCLUSIVE
840 Tape Input and Output










