Input/Ouput - DCB - DD

Assembler Input/Output - DCB's - DD's
The way to process input and output within an assembler program is to write a DCB within the program detailing what the file looks like, then incorporating that DCB name within the JCL to run the program utilizing a DD statement that points to the actual file being worked with. This is illustrated below:



Format for DCB's
INPUT:



OUTPUT:



DCB Breakdown
Purpose Use the DCB macro to create a Data Control Block for one of your files.

For a program to process a file through BSAM or QSAM, a data control block (DCB) must be created for it. A DCB contains information that defines the characteristics of the data in the file and describes the I/O device requirements for handling the data.

Usually the DCB macro is issued sometime after the FILEDEF command is issued. The FILEDEF command provides similar information about your file. Together, the FILEDEF command and the DCB macro provide all the information necessary to the data control block. It is possible for the DCB macro to provide all data for the data control block without the help of the FILEDEF command. For more information on the FILEDEF command see FILEDEF. Parameters It is required that the DSORG and MACRF parameters be specified in the DCB macro. The other parameters may be supplied through the:
 * DCB macro
 * FILEDEF command
 * Physical characteristics of the file
 * Direct insertion of a parameter's value or attribute into the data control block by your program. This is not too difficult, if you take advantage of the DCBD macro. See DCBD (BSAM/QSAM).However, you must be careful to insert the value in the DCB in a timely fashion. For example, it would be useless to insert the value of the DDNAME or the EXLST after issuing the OPEN macro, because that macro needs those values to process correctly.
 * BLKSIZE
 * Specifies the maximum block length for the file, in bytes. For fixed-length, unblocked records, this parameter specifies the maximum individual record length.If your file contains variable-length records, then the value specified by this parameter must include 4 extra bytes to accommodate the block descriptor word (BDW). In such a case, you can write this parameter as any number from 8 to 32756, plus 4 bytes for the BDW. (The OPEN macro simulation routine will not accept a BLKSIZE of less than eight.)

If your file contains undefined-length records, then the field in the DCB associated with this parameter (the DCBBLKSI field) can be filled in with the exact value after it is known by your program. Alternatively, it can be specified in the LENGTH parameter of a READ or WRITE instruction. See READ (BSAM) and WRITE (BSAM).
 * DDNAME
 * Specifies the name by which the file in question is known within your program. This parameter corresponds exactly with the DDNAME parameter in the FILEDEF command.You can write this parameter as any label of from one to eight alphanumeric characters. The first character must be alphabetic or national.


 * DSORG=PS
 * Indicates that your file consists of physical sequential records.Because GCS supports only physical sequential file processing, this parameter is required.


 * EODAD
 * Specifies the address of a routine that is to receive control when the end of an input file is reached.It is your responsibility to provide this routine. Obviously you are only required to do so when the file, whose DCB you are creating, is an input file. You define whether it is an I/O file in the MACRF parameter as described in the following.

When GCS receives a request for input (for example, through a READ macro) and the next CHECK macro indicates that the end of the file has been reached, then this EODAD routine automatically receives control.

If this parameter is omitted and the END-OF-FILE condition is raised in an input file, then control is given to the routine whose address you specify in the SYNAD parameter, as described in the following. If you omit both the EODAD and the SYNAD parameters, and the END-OF-FILE condition occurs, then your task terminates abnormally.

You can write this parameter as an RX-type address or as register (2) through (12).
 * LRECL
 * Fixed-length record files, this parameter specifies the length, in bytes, of each record. You can write this as a number from 1 to 32760.Variable-length record files, this parameter specifies the maximum length of any record in the file. You can write this as a number from 1 to 32752, plus 4 bytes for the record descriptor word (RDW).

It may happen that you omit this parameter in both the FILEDEF command and the DCB macro. If so, and if the file already exists, then the current LRECL value is obtained from the actual length of the file's records. However, if your file is newly created, then its logical record length must be supplied in one of the ways listed earlier. Otherwise it is considered an error.
 * MACRF
 * Specifies the type of macros that you will use to process the file in question. In effect, you use this parameter to define whether you will treat it as an input file or an output file. Also, you are stating what mode of data transmission you will use in moving data in to or out of the file.
 * R
 * (BSAM) Specifies that the READ macro will be used. See READ (BSAM).
 * W
 * (BSAM) Specifies that the WRITE macro will be used. See WRITE (BSAM).
 * RP
 * (BSAM) Specifies that the READ and POINT macros will be used. See POINT (BSAM).Specifying the RP parameter gives you the added capability of using the NOTE macro. See NOTE (BSAM).
 * WP
 * (BSAM) Specifies that the WRITE and POINT macros will be used.The WP parameter gives you the added capability of using the NOTE macro.
 * GM
 * (QSAM) Specifies that the GET macro in MOVE mode will be used. MOVE mode is defined in GET (QSAM).
 * GL
 * (QSAM) Specifies that the GET macro in LOCATE mode will be used. LOCATE mode is defined in GET (QSAM).
 * PM
 * (QSAM) Specifies that the PUT macro in MOVE mode will be used. MOVE mode is defined in PUT (QSAM).
 * PL
 * (QSAM) Specifies that the PUT macro in LOCATE mode will be used. LOCATE mode is defined in PUT (QSAM).


 * RECFM
 * Specifies the record format of your file.For an existing file, the currently assigned record format is used unless another is specified. For a new file whose DCB you are creating, the record format is undefined, by default, unless one is specified.

Select from among the following record formats.


 * VB
 * Indicates that the records in your file are variable long, according to the LRECL parameter. It also indicates that these records are to be blocked according to the BLKSIZE parameter specified here or in the FILEDEF command.
 * VBA
 * Indicates the same as the VB parameter but also indicates that your file contains ANSI control characters.
 * FB
 * Indicates that each record in your file is of a fixed length, according to the LRECL parameter. Likewise, these records are to be blocked, according to the BLKSIZE parameter as specified here or in the FILEDEF command.
 * FBA
 * Indicates the same as the FB parameter but also indicates that your file contains ANSI control characters.
 * F
 * Indicates that each record in your file is of a fixed length, according to the LRECL parameter.
 * V
 * Indicates that the records in your file are variable long, according to the LRECL parameter.
 * FA
 * Indicates that your file is composed of fixed-length records that contain ANSI control characters.
 * VA
 * Indicates that your file is composed of variable-length records that contain ANSI control characters.
 * U
 * Indicates that the record format of your file is undefined. If the RECFM parameter is omitted, then the record format of the file is undefined, by default.
 * UA
 * Indicates that the record format of your file is undefined. It also indicates that your file contains ANSI control characters.
 * OPTCD=J
 * Indicates that the first byte in the output data stream will be a 3800 table reference character.Such a character selects a particular character arrangement table for the printing of the output data stream on a 3800 printing subsystem. You can use this character with ANSI control characters, if you wish.
 * SYNAD
 * Specifies the address of your error routine that is to receive control when an irrecoverable I/O error occurs.Under BSAM, this SYNAD routine receives control when the CHECK macro is issued. Under QSAM, it receives control automatically during the processing of the GET or PUT macro.

If you provide no error routine and an irrecoverable I/O error occurs, then your task terminates abnormally.

If you provide an error routine and an error occurs, then GCS automatically saves your program's registers and turns control over to your error routine. You must design your error routine in such a way that it does not use the register save area pointed to by register 13. This save area is for your program's registers. If your error routine needs a register save area, it must construct and maintain one of its own.

Your error routine can issue the RETURN macro, using the address in register 14, to return control to GCS. If control returns to GCS, then GCS returns control to the problem program, which can then proceed as though no error occurred. SeeRETURN.

You can write the SYNAD parameter as an RX-type address or as register (2) through (12). Remember, your program can change the address in this parameter anytime.

Input Output Commands


OPEN macro:

Purpose Use the OPEN macro to open a file and prepare it for processing.

Before a program can use a file, they must be logically connected to each other. That is, GCS must be told where the file is and what its characteristics are. Usually this process is calledopening the file. Parameters


 * dcb_address
 * Specifies the address of the data control block associated with the file you want to open. For example, it is the address of the label on the DCB macro associated with your file. SeeDCB (BSAM/QSAM).You can write this parameter as an RX-type address or as register (2) through (12).


 * INPUT
 * Indicates that your file is to be treated as an input file. Unless otherwise specified, this parameter applies by default.


 * OUTPUT
 * Indicates that your file is to be treated as an output file.You must specify this parameter if you are creating a new file.


 * UPDAT
 * Indicates that you intend to update an already existing file.

Usage


 * 1) Use of the OPEN macro to open a file assumes that the DCB macro has also been issued for that file.
 * 2) The OPEN macro prepares your file for processing, then logically connects it to your program.First, the information you supplied using the DCB macro and the FILEDEF command are merged into one data control block. For more information on the FILEDEF command, seeFILEDEF.

Where an existing file is concerned, if any information necessary to the data control block is not provided by either of these sources, then it is taken from the attributes of the file itself.

Later, the exit routines specified in the DCB macro are executed and the processing method of your file (INPUT, OUTPUT, or UPDAT) is designated. After a few other details are taken care of, your file is ready for processing.
 * 1) More than one file may be opened by a single OPEN macro. Just be certain that a comma delimits each entry in the list and that the entire list is surrounded by parentheses.
 * 2) When choosing from among the INPUT, OUTPUT, and UPDAT parameters, be mindful of what was specified by the DCB macro in the MACRF parameter. In this respect, the OPEN and DCB macros must be compatible.For example, if input macros were specified by the MACRF parameter, then the INPUT parameter must be applied to the corresponding OPEN macro.
 * 3) Only the task that opened a file can close it.
 * 4) To try to open a file that is already opened, with the same DCB, amounts to issuing a NOP (NO OPERATION) instruction.
 * 5) It is an error to open a file specifying a DCB address that is not really the address of a data control block. The results of such an error are unpredictable.
 * 6) If you have access method control blocks (ACBs) that you wish to open, and DCBs, then you can specify a combination of both in the same OPEN macro. GCS is able to distinguish the address of one from the address of the other, if you separate each with a comma.

GET Macro:

Example:    GET    INFILE,INREC

For data sets accessed with the queued sequential access method (QSAM), use the GET macro to obtain data from auxiliary storage. GET obtains a record from an input data set (as opposed to a block) and places it in a designated area of virtual storage (a buffer). Buffers can be allocated by you or by the operating system and are filled each time a GET is issued.

GET provides various modes that can be specified in the DCB macro. These modes include:


 * Locate
 * Move.