Optimizing buffer and device space
Use the APPLY WRITE-ONLY
clause to make
optimum use of buffer and device space when you create a sequential
file with blocked variable-length records.
About this task
With APPLY WRITE-ONLY
specified, a
buffer is truncated only when the next record does not fit in the
unused portion of the buffer. Without APPLY WRITE-ONLY
specified,
a buffer is truncated when it does not have enough space for a maximum-size
record.
The APPLY WRITE-ONLY
clause has meaning
only for sequential files that have variable-length records and are
blocked.
The AWO
compiler option applies an
implicit APPLY WRITE-ONLY
clause to all eligible
files. The NOAWO
compiler option has no effect on
files that have the APPLY WRITE-ONLY
clause specified.
The APPLY WRITE-ONLY
clause takes precedence over
the NOAWO
compiler option.
- The file processing occurs in the record area and the data in the record area can be accessed by
the program if one of the following is true:
- The file is EXTERNAL
- The file is contained in a "
SAME RECORD AREA
" statement in the I-O-CONTROL section - The program is compiled with the
AWO
compiler option
- The file processing typically occurs in a buffer and the data in the record area is not
guaranteed to be accessible by the program (storage undefined) if all of the following is true:
- The file is not EXTERNAL
- The file is not contained in a "
SAME RECORD AREA
" statement in the I-O-CONTROL section - The program is compiled with the
NOAWO
compiler option
FD MY-INPUT-FILE
LABEL RECORDS ARE STANDARD
RECORDING MODE IS V
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS IN-RECORD-AREA.
01 IN-RECORD-AREA PIC X(100).
WORKING-STORAGE.
01 WS-IN-RECORD-AREA PIC X(100).
PROCEDURE DIVISION.
...
READ MY-INPUT-FILE INTO WS-IN-RECORD-AREA.