Rational Developer for System z
Enterprise PL/I for z/OS, Version 3.9, Programming Guide

Accessing and updating a data set with record I/O

Once you create a consecutive data set, you can open the file that accesses it for sequential input, for sequential output, or, for data sets on direct access devices, for updating. See Figure 31 for an example of a program that accesses and updates a consecutive data set. If you open the file for output, and extend the data set by adding records at the end, you must specify DISP=MOD in the DD statement. If you do not, the data set will be overwritten. If you open a file for updating, you can update only records in their existing sequence, and if you want to insert records, you must create a new data set. Table 16 shows the statements and options for accessing and updating a consecutive data set.

When you access a consecutive data set by a SEQUENTIAL UPDATE file, you must retrieve a record with a READ statement before you can update it with a REWRITE statement; however, every record that is retrieved need not be rewritten. A REWRITE statement will always update the last record read.

Consider the following:

READ FILE(F) INTO(A);
     .
     .
     .
READ FILE(F) INTO(B);
     .
     .
     .
REWRITE FILE(F) FROM(A);

The REWRITE statement updates the record that was read by the second READ statement. The record that was read by the first statement cannot be rewritten after the second READ statement has been executed.

To access a data set, you must identify it to the operating system in a DD statement. Table 20 summarizes the DD statement parameters needed to access a consecutive data set.

Table 20. Accessing a consecutive data set with record I/O: essential parameters of the DD statement
Parameters What you must state When required
DSNAME=
 
DISP=
Name of data set
 
Disposition of data
set
Always
UNIT= or VOLUME=REF= Input device If data set not cataloged (all devices)
VOLUME=SER= Volume serial number If data set not cataloged (direct access)
DCB=(BLKSIZE= Block size1 If data set does not have standard labels
Notes:
1Or you could specify the block size in your PL/I program by using the ENVIRONMENT attribute.

The following paragraphs indicate the essential information you must include in the DD statement, and discuss some of the optional information you can supply. The discussions do not apply to data sets in the input stream.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)