File Declarations
1. DECLARATION
DCL filename FILE [INPUT|OUTPUT] [STREAM|RECORD] ENV (options).
2. ENVIRONMENT Attribute
l It can be omitted if equivalent information is given in the JCL.
l The options applicable to STREAM files are record form and record size
ENV(F BLKSIZE(80)) Specifies
Record type is fixed
Each record is 80 byte long
3. PRINT Attribute
l Added for stream files associated with a printer.
l Applies only to files with STREAM and OUTPUT attributes.
l It causes the initial byte of each record of the associated data set to be reserved for printer control character (which does not appear in the printout) through the use of PAGE, SKIP, LINE.
Eg.
DCL PRINTR FILE OUTPUT STREAM PRINT ENV(F BLKSIZE(133));
DCL AREA CHAR(132);
PUT FILE (PRINTR) PAGE LIST(AREA);
l If the PRINT attribute is removed form the declare, we can have a blocksize of 132 instead of 133.
l Quote marks are supplied by list directed output routines around character strings output to non-PRINT files. In the above example if the area size is 130, the record length will still be 132.
l Builtin function LINENO finds the current line number for a file having the PRINT attribute and returns that number to the point of invocation. e.g.
I = LINENO(PRINTR).
4. DEFAULT or PREDEFINED FILES
n SYSIN is the default standard input file.
n SYSPRINT is the default standard output file.
u GET LIST(A,B) is equal to GET FILE(SYSIN) LIST(A,B)
u PUT LIST(A,B) is equal to PUT FILE(SYSPRINT) LIST(A,B)
n SYSIN and SYSPRINT file names and their attributes need not be declared for IBM implementations. The default attributes are:
u SYSIN FILE STREAM INPUT ENV(F BLKSIZE(80))
u SYSPRINT FILE STREAM OUTPUT PRINT ENV(V BLKSIZE(129))
5. OPEN STATEMENT
OPEN FILE(文件名) [ STREAM|RECORD ] [SEQUENTIAL|DIRECT]
[ INPUT|OUTPUT|UPDATE ] [ PRINT LINESIZE(nn) PAGESIZE(nn)];
l FILE(文件名) 文件名:程序中使用的必须与JCL中的DD名一致
l 数据传送类型默认为STREAM
l RECORD方式传送数据时使用的读取属性,默认为SEQUENTIAL
l 印刷属性STREAM,OUTPUT时有效
LINESIZE: 一行的长度,默认为120
PAGESIZE: 一页的行数,默认为60
l Some attributes of the file may be specified in the JCL, some (but not conflicting ones ) in the Declare and the remaining in the OPEN statement. At OPEN time attributes from these three sources are combined to form the description of the file which the program is going to communicate.
l Stream files are automatically opened when the first GET or PUT is issued.
e.g.
OPEN FILE (PRINTR) PAGESIZE(50);
OPEN FILE(SYSPRINT) LINESIZE(133);
Note: If LINESIZE is used we need not specify the BLKSIZE in the declare stmt.
Pagesize and Linesize cant be used in the declare statement.