CLOSE—Disconnect program and data (BDAM, BISAM, BPAM, BSAM, QISAM, and QSAM)

The CLOSE macro creates output data set labels and allows you to position volumes. The fields of the data control block (DCB) and DCBE are restored to the condition that existed before the OPEN macro was issued, and the data set is disconnected from the processing program. You can specify final volume positioning or disposition for the current volume to override the positioning implied by the DISP parameter of the DD statement. Any number of dcb address parameters and associated options can be specified in the CLOSE macro.

After a CLOSE has been issued for several data sets, a return code of 4 indicates that at least one of the data sets, VSAM or non-VSAM, was not closed successfully.

A FREEPOOL macro should normally follow a CLOSE macro (without TYPE=T) to regain the buffer pool storage space if OPEN or GETPOOL built the buffer pool. This also allows a new buffer pool to be built if the DCB is reopened with different record size attributes. However, if you requested via the DCBE that OPEN obtain QSAM buffers above the line, CLOSE frees the buffer pool obtained by OPEN. Therefore, in this case, a FREEPOOL macro is not required following the CLOSE macro.

Associated data sets for an IBM® 3525 Card Punch can be closed in any sequence, but, if one data set is closed, I/O operations cannot be initiated for any of its associated data sets. Additional information about closing associated data sets is contained in z/OS DFSMS Using Data Sets.

A special parameter, TYPE=T, temporary close, is provided for processing with BSAM.

The CLOSE macro does not support more than a total of 255 spooled, SUBSYS or compressed format data sets, for one invocation.

If you use a "reserved" relative generation number character as the first character of a member name, the stow will not occur, you must issue your own stow.

Extended format data sets: If you request release of unused space for extended format data sets, CLOSE releases space on each stripe if possible. After the space is released, the size of some stripes may differ slightly from others. Depending on the unit used for allocation, the difference will be at most one track or cylinder.

When a compressed format data set is written using BSAM or QSAM, the CLOSE macro ensures that all data has been synchronized to DASD.

PDS and PDSE data sets: If the PDS or PDSE is open for OUTPUT, OUTIN or INOUT, and a member name was specified in the JCL (or JFCB with OPEN TYPE=J), and the last operation was either a WRITE (BSAM) or a PUT (QSAM), and the application has not issued its own STOW, then CLOSE will issue a STOW. However, if the first character of the member name is '+' (X'4E'), '-' (X'60'), or (X'Fx'), CLOSE will not issue STOW. This is because these characters identify the generation data set (GDS) within a generation data group (GDG), and the access method uses the first character of the member name field in the JFCB to distinguish between a GDS identifier and a member name.

PDSEs: After PDSE members are written or updated using BSAM or QSAM, the CLOSE macro synchronizes member data to DASD.

UNIX files: When a file is written using BSAM or QSAM, the CLOSE macro ensures that all data has been synchronized to the file.

SMF records: CLOSE does not write SMF type 14/15 records for UNIX files. DFSMS relies on z/OS UNIX to write appropriate SMF records when requested by the system programmer.

The CLOSE macro may be issued in 24- or 31-bit addressing mode. When issued in 31-bit addressing mode, all addresses must be valid 31-bit addresses.

The standard form of the CLOSE macro is as follows (the list and execute forms are shown following the description of the standard form):

dcb address—A-Type Address or (2-12)
specifies the address of the data control block for the opened data set to be closed.

Requirement: If the register format is used, then the register must be enclosed within parentheses. For example, CLOSE ((2)).

option
Each of these options indicates the volume positioning to occur when the data set is closed. These options are generally used with TYPE=T for data sets on magnetic tape. However, options specified in the CLOSE macro override disposition specifications in the JCL for all data sets. The options are:
REREAD
specifies that the current volume is to be positioned to reprocess the data set. If processing was forward, the volume is positioned to the beginning of the data set. If processing was backward (RDBACK), the volume is positioned to the end of the data set. If FREE=CLOSE is specified in the JCL, the data set is not unallocated until the end of the job step.
LEAVE
specifies that the current volume is to be positioned to the logical end of the data set. If processing was forward, the volume is positioned to the end of the portion of the data set residing on the current volume. If processing was backward (RDBACK), the volume is positioned to the beginning of the portion of the data set residing on the current volume. If FREE=CLOSE is specified in the JCL, the data set is not unallocated until the end of the job step.
REWIND
specifies that the current magnetic tape volume is to be positioned at the load point, regardless of the direction of processing. REWIND cannot be specified when TYPE=T is specified. If FREE=CLOSE is coded on the DD statement associated with the data set being closed, coding the REWIND option frees the data set when it is closed rather than at the end of the job step.
FREE
specifies that the current data set is freed when the data set is closed, rather than when the job step terminates. For tape data sets, this means that the volume is eligible for use by other tasks or to be demounted. Direct access volumes can also be freed for use by other tasks. They can be freed for demounting if (1) no other data sets on the volume are open and (2) the volume is otherwise demountable. Do not use this option with CLOSE TYPE=T. (For other restrictions on the FREE parameter, see z/OS MVS JCL Reference.)
DISP
specifies that a tape volume is to be disposed of in the manner implied by the DD statement associated with the data set. Direct access volume positioning and disposition are not affected by this parameter. There are several dispositions that can be specified in the DISP parameter of the DD statement; DISP can be PASS, DELETE, KEEP, CATLG, or UNCATLG.
Depending on how the DISP option is coded in the DD statement, the current magnetic tape volume is positioned as follows:
DISP Parameter Action
PASS Forward space to the end of data set on the current volume.
DELETE Rewind the current volume.
KEEP, CATLG, or UNCATLG The volume is rewound and unloaded, if necessary.

If FREE=CLOSE is coded in the DD statement associated with this data set, coding the DISP option in the CLOSE macro results in the data set being freed when the data set is closed, rather than at the time the job step is terminated.

When the option subparameter is omitted, DISP is assumed. For TYPE=T, this is processed as LEAVE during execution. The LEAVE and REREAD options are used only for magnetic tape or CLOSE TYPE=T.

TYPE=T
You can code CLOSE TYPE=T to temporarily close sequential data sets on magnetic tape and direct access volumes processed with BSAM. When you use TYPE=T, the DCB used to process the data set maintains its open status, and you should not issue another OPEN macro to continue processing the same data set. This option cannot be used in a SYNAD exit routine.

TYPE=T causes the system control program to process labels, modify some of the fields in the system control blocks for that data set, and reposition the volume (or current volume for multivolume data sets) in much the same way that the normal CLOSE macro does.

When you code TYPE=T, you can specify that the volume either be positioned at the end of data (the LEAVE option) or be repositioned at the beginning of data (the REREAD option). Magnetic tape or DASD volumes are repositioned either immediately before the first data record or immediately after the last data record. The presence of tape labels has no effect on repositioning.

For PDSEs and partitioned data sets, CLOSE TYPE=T does no operation except when reading the PDSE or partitioned data set directory sequentially. If you code CLOSE TYPE=T with the REREAD option, the data set is repositioned to the beginning of the directory.

If you code the RLSE keyword with the SPACE parameter on the DD statement that describes the output data set, it is ignored by temporary close (CLOSE TYPE=T). If the last operation occurring before the normal CLOSE (without TYPE=T) and after the temporary close was a write, then any unused space is released.

For extended format data sets open for output, CLOSE TYPE=T updates the data set label for each stripe to correctly reflect the used space on each volume.

While an extended format data set is open for output, the data set labels do not correctly reflect the used space in the data set. An open to an input or update DCB (while the output DCB is still open for output) will not reflect the correct data set size of an extended format data set. You may choose to issue a CLOSE LEAVE,TYPE=T on the output DCB to cause subsequent OPENs for input/update to reflect the correct amount of used space. CLOSE TYPE=T is ignored for a FIFO and character special UNIX file.

MODE=24|31
You can code CLOSE MODE=31 to specify a long form parameter list that can contain 31-bit addresses. The default, MODE=24, specifies a short form parameter list with 24-bit addresses. Your program does not need to be executing in 31-bit addressing mode to use MODE=31 in the CLOSE macro. This parameter specifies the form of the parameter list, not the addressing mode of the program.

The caller of the standard form of the macro with the short form of the parameter list must reside below the 16MB line, but the caller can be executing in 31-bit mode. All access method control blocks (ACBs) and DCBs are below the 16MB line.

The long form parameter list can reside above or below the 16MB line. Although the access method control block (ACB) or DCB address is contained in a 4-byte field, the DCB must be below the 16MB line. Except for VSAM or Virtual Telecommunications Access Method (VTAM®) ACBs, all ACBs must also be below the 16MB line. Therefore, the leading byte of the ACB or DCB address must contain zeros. If the byte contains something other than zeros, an IEC290I message is issued and the data set is not closed.

For additional information and coding restrictions, see z/OS DFSMS Using Data Sets.