• Aucun résultat trouvé

Opening and Closing a Data Set

Dans le document OS Data Management Services Guide (Page 60-65)

Although your program has been assembled, the various data management routines required for I/O operations are not a part of the object code. In other words, your program is not completely assembled until the DCBs are initialized for execution. You accomplish initialization by issuing the OPEN macro instruction. After all DCBs have been completed, the system ensures that all required access method routines are loaded and ready for use and that all channel command word lists and buffer areas are ready.

44 OS Data Management Services

Access method routines are selected and loaded according to data control fields that indicate:

Data organization Buffering technique Access technique I/O unit characteristics

This information is used by the system to allocate main-storage space and load the appropriate routines. These routines, the channel command word (CCW) lists, and buffer areas created automatically by the system remain in main storage until the Close routine signals that they are no longer needed by the DCB that was using them.

When I/O operations for a data set are completed, you should issue a CLOSE macro instruction to return the DCB to its original status, handle volume disposition, create data set labels, complete writing of queued output buffers, and free main and auxiliary storage.

After closing the data set, you should issue a FREEPOOLmacro instruction to release the main storage used for the buffer pool. If you plan to process other data sets, use FREEPOOL to regain the buffer pool storage space. If you expect to reopen a data set using the same DCB, use FREEPOOL unless the buffer pool created the first time the data set was opened will meet your needs when you reopen the data set.

FREEPOOL is discussed in more detail in the section "Buffer Pool Construction."

After the data set has been closed, the DCB can be used for another data set. If you do not close the data set before a task terminates, the operating system closes it automatically. If the DCB is not available to the system at that time, the operating system abnormally terminates the task, and data results can be unpredictable. Note, however, that the operating system cannot automatically close any open data sets after the normal termination of a program that was brought into main storage by the loader.

Therefore, loaded programs must include CLOSE macro instructions for all open data sets.

An OPEN or CLOSE macro instruction can be used to initiate or terminate processing of more than one data set. Simultaneous opening or closing is faster than issuing separate macro instructions; however, additional storage space is required for each data set specified.

Notes:

Two or more DCBs should never be opened concurrently for output to the same data set on a direct-access device, except with the indexed sequential access method (ISAM). Otherwise the end-of-file record written by the CLOSE for one DeB may overlay data associated with another DCB.

• Two or more DCBs should never be opened concurrently using the same DDname. This is true for both input and output and especially important when you are using more than one access method. Any action on one DCB that alters the task input/output table (TIOT) or JFCB affects the other DCB(s) and thus can cause unpredictable results.

If you want to use the same DD statement for two or more DCBs, you cannot specify parameters for fields in the first DCB and then be assured of obtaining the default parameters for the same fields in any subsequent DCB using the same

Part 2: Data Management Processing Procedures 45

DD statement. Therefore, unless the parameters of all DCBs using one DD statement are the same, you should use separate DD statements.

• Associated data sets for the 3525 Card Punch can be opened in any order, but all data sets must be opened before any processing can begin. Associated data sets can be closed in any order, but once a data set has been closed, I/O operations cannot be performed on any of the associated data sets. See "Appendix C:

Special Programming Considerations for the 3505 Card Reader and the 3525 Card Punch" for more information.

Volume disposition specified in the OPEN or CLOSE macro instruction can be overridden by the system if necessary. However, you need not be concerned; the system automatically requests the mounting and demounting of volumes, depending upon the availability of devices at a particular time.

OPEN - Initiate Processing of a Data Set

The OPEN macro instruction is used to complete a data control block for an associated data set. The method of processing and the volume positioning instruction in the event of an end-of-volume condition can be specified.

Processing Method: You can process a data set as either input or output (by coding INPUT or OUTPUT as the processing method operand of the OPEN macro) or, under

I

BSAM, a combination of the two (by coding INOUT or OUTIN). Associated data sets to be processed concurrently on the 3525 Card Punch must have separate DCBs for each data set. See "Appendix C: Special Programming Considerations for the 3505 Card Reader and the 3525 Card Punch" for more information. If the data set resides on a direct-access volume, you can code UPDAT in the processing method operand to indicate that records can be updated. To specify that a magnetic-tape volume is to be read backward by BSAM or QSAM, code RDBACK in this operand. If the processing method operand is omitted from the OPEN macro instruction, INPUT is assumed. The operand is ignored by the basic indexed sequential access method (BISAM); it must be specified as OUTPUT when you are using the queued indexed sequential access method (QISAM) to create an indexed sequential data set. You can override the INOUT and OUTIN at execution by using the LABEL parameter of the DD statement, as discussed in OS Job Control Language Reference.

Simultaneous Opening of Data Sets: In Figure 25, the data sets associated with three DCBs are to be opened simultaneously.

OPEN (TEXTDCB"CONVDCB,(OUTPUT),PRINTDCB,(OUTPUT))

+ CNOP 0,4

+ BAL 1,*+16 Load register with list address

+ DC AL 1 (0) Option byte

+ DC AL3(TEXTDCB) DCB address

+ DC AL 1 ( 15 ) Option byte

+ DC AL3(CONVDCB) DCB address

+ DC AL 1 ( 143 ) Option byte

+ DC AL3(PRINTDCB) DCB address

+ SVC 19 Issue open SVC

Figure 25. Opening Three Data Sets Simultaneously

Since no processing method operand is specified for TEXTDCB, the system assumes INPUT. Both CONVDCB and PRINTDCB are opened for output. No volume

46 OS Data Management Services

positioning options are specified; thus, the position indicated by the DD statement DISP parameter is used.

At execution, the SVC 19 instruction passes control to the Open routine, which then initializes the three DCBs and loads the appropriate access method routines.

CLOSE - Terminate Processing of a Data Set

The CLOSE macro instruction is used to terminate processing of a data set and release it from a DCB. The volume positioning that is to result from closing the data set can also be specified. Volume positioning options are the same as those that can be specified for end-of-volume conditions in the OPEN macro instruction or the DD statement. An additional volume positioning option, REWIND, is available and can be specified by the CLOSE macro instruction for magnetic-tape volumes. REWIND positions the tape at the load point regardless of the direction of processing.

The operating system provides a temporary closing option, CLOSE (TYPE=T), for data sets being processed by BSAM. This option cannot be used if you are using BSAM to create a direct data set (MACRF= WL coded in the DCB macro instruction).

CLOSE (TYPE=T) causes the RLSE parameter on the DD card to be ignored. When the macro instruction is executed for data sets on magnetic-tape or direct-access volumes, the system processes labels and repositions the volume as required. However, the DCB maintains its open status. You can continue processing of the data set at a later stage in your program without reissuing the OPEN macro instruction, thus improving performance. Magnetic-tape volumes are repositioned to the point either preceding the first data block or following the last data block of the data set. The presence of tape labels has no effect on repositioning.

Simultaneous Closing of Data Sets: In Figure 26, the data sets associated with three DCBs are to be closed simultaneously.

CLOSE (TEXTDCB"CONVDCB"PRINTDCB)

+ CNOP 0,4

+ BAL 1 , *+ 16 Branch around list

+ DC AL1(0) Option byte

+ DC AL3(TEXTDCB) DCB address

+ DC AL1(0) Option byte

+ DC AL3(CONVDCB) DCB address

+ DC AL1( 128) Option byte

+ DC AL3(PRINTDCB) DCB address

+ SVC 20 Issue close SVC

Figure 26. Closing Three Data Sets Simultaneously

Because no volume positioning operands are specified, the position indicated by the DD statement DISP parameter is used.

At execution, the SVC 20 instruction passes control to the Close routine, which

terminates processing of the three data sets and returns the three DCBs to their original status.

Part 2: Data Management Processing Procedures 47

End-of-Volume Processing

Control is passed automatically to the data management end-of-volume routine when any of the following conditions is detected:

• End-of-data indicator (input volume)

• Tapemark (input tape volume) Filemark (input direct-access volume) End of reel (output tape volume)

End of extent (output direct-access volume)

You may issue a force end-of-volume (FEOV) macro instruction before the end-of-volume condition is detected.

The end-of-volume routine checks or creates standard trailer labels, if the LABEL parameter of the associated DD statement indicates standard labels. Control is then passed to the appropriate user label routine if it is specified in your exit list.

If multiple-volume data sets are specified in your DD statement, automatic volume switching is accomplished by the end-of -volume routine. When an end-of -volume condition exists on an output data set, additional space is allocated as indicated in your DD statement. If no more volumes are specified or if more than specified are required, the storage is obtained from any available volume on a device of the same type. If no such volume is available, your job is terminated.

Volume Positioning: When an end-of -volume condition is detected, the system positions the volume according to the disposition specified in the DD statement unless the volume disposition is specified in the OPEN macro instruction. Volume positioning instructions for a sequential data set on tape or direct access can be specified as LEAVE or REREAD.

LEAVE

positions the volume at the logical end of the data set just read or written. If the data set has been read backward, the logical end is the physical beginning of the data set.

REREAD

positions the volume at the logical beginning of the data set just read or written.

A volume positioning instruction can be specified only if the processing method operand has been specified. It is ignored if devices other than magnetic-tape and direct-access are used, or if the number of volumes exceeds the number of available units.

For magnetic-tape volumes, positioning varies according to the direction of the last input operation and the existence of tape labels. If the tape was last read forward:

LEAVE

positions a labeled tape to the point following the tapemark that follows the data set trailer label group, and an unlabeled volume to the point following the tapemark that follows the last block of the data set.

48 OS Data Management Services

REREAD

positions a labeled tape to the point preceding the data set header label group, and an unlabeled tape to the point preceding the first block of the data set.

If the tape was last read backward:

LEAVE

positions a labeled tape to the point preceding the data set header label group, and an unlabeled tape to the point preceding the first block of the data set.

REREAD

positions a labeled tape to the point following the tapemark that follows the data set trailer label group, and an unlabeled tape to the point following the tape mark that follows the last block of the data set.

FEOV - Force End of Volume

The FEOVmacro instruction directs the operating system to initiate end-of-volume processing before the physical end of the current volume is reached. If another volume has been specified for the data set, volume switching takes place automatically. The volume positioning options REWIND and LEA VE are available.

The FEOV macro instruction can only be used when you are using BSAM or QSAM.

Dans le document OS Data Management Services Guide (Page 60-65)