Opening an empty file
To open a file that has never contained records (an empty
file), use a form of the OPEN
statement.
Depending on the type of file that you are opening, use one of the following statements:
OPEN OUTPUT
for ESDS files.OPEN OUTPUT
orOPEN EXTEND
for KSDS and RRDS files. (Either coding has the same effect.) If you coded the file for random or dynamic access and the file is optional, you can useOPEN I-O
.
Optional
files are files that are not necessarily available each time
a program is run. You can define files opened in INPUT
, I-O
,
or OUTPUT
mode as optional by defining them with
the SELECT OPTIONAL
clause in the FILE-CONTROL
paragraph.
Initially loading a file sequentially: Initially loading a file means writing records into the file for the first time. Doing so is not the same as writing records into a file from which all previous records have been deleted. To initially load a VSAM file:
- Open the file.
- Use sequential processing (
ACCESS IS SEQUENTIAL
). (Sequential processing is faster than random or dynamic processing.) - Use
WRITE
to add a record to the file.
Using OPEN OUTPUT
to load a VSAM file
significantly improves the performance of your program. Using OPEN
I-O
or OPEN EXTEND
has a negative effect
on the performance of your program.
When you load VSAM indexed files sequentially, you optimize both loading performance and subsequent processing performance, because sequential processing maintains user-defined free space. Future insertions will be more efficient.
With ACCESS
IS SEQUENTIAL
, you must write the records in ascending RECORD
KEY
order.
When you load VSAM relative files sequentially, the records are placed in the file in the ascending order of relative record numbers.
Initially loading
a file randomly or dynamically: You can use random or dynamic
processing to load a file, but they are not as efficient as sequential
processing. Because VSAM does not support random or dynamic processing,
COBOL has to perform some extra processing to enable you to use ACCESS
IS RANDOM
or ACCESS IS DYNAMIC
with OPEN
OUTPUT
or OPEN I-O
. These steps prepare
the file for use and give it the status of a loaded file because it
has been used at least once.
In addition to extra overhead for preparing files for use, random processing does not consider any user-defined free space. As a result, any future insertions might be inefficient. Sequential processing maintains user-defined free space.
When you are loading an extended-format VSAM data set,
file status 30 will occur for the OPEN
if z/OS® DFSMS system-managed buffering
sets the buffering to local shared resources (LSR). To successfully
load the VSAM data set in this case, specify ACCBIAS=USER
in
the DD AMP
parameter for the VSAM data set to bypass
system-managed buffering.
Loading
a VSAM data set with access method services: You can load or update
a VSAM data set by using the access method services REPRO
command.
Use REPRO
whenever possible.
Statements to load records into a VSAM file
z/OS DFSMS: Access Method Services for Catalogs (REPRO)