- File program - for writing into a file:
WRITFILA: /* TO WRITE A FILE */
PROC OPTIONS(MAIN) REORDER ;
DCL RDFIL FILE RECORD OUTPUT;
SYSPRINT FILE PRINT EXTERNAL ;
DCL 1 INSURANCE,
5 INS_NAME CHAR(20),
5 AGE PIC '(2)9',
5 CO_NAME CHAR(25),
5 PRD_CODE CHAR(3),
5 SUMASSURED PIC '(5)9',
3 FILLER CHAR(25);
DCL EOF CHAR(1) INIT('Y');
OPEN FILE (RDFIL);
DO WHILE (EOF = 'Y');
GET SKIP LIST(INSURANCE.INSURER.INS_NAME);
GET SKIP LIST(INSURANCE.INSURER.AGE);
GET SKIP LIST(INSURANCE.COMPANY.CO_NAME);
GET SKIP LIST(INSURANCE.COMPANY.PRD_CODE);
GET SKIP LIST(INSURANCE.COMPANY.SUMASSURED);
WRITE FILE (RDFIL) FROM (INSURANCE);
GET SKIP LIST (EOF);
END; /* DO WHILE (EOF = Y) */
CLOSE FILE (RDFIL);
END; /* PROGRM END */
--In JCL the name of the file which you mentioned in the program should be given as step name.
File name can be from 1 to 7 characters long.
File attributes include
Type of transmission. (STREAM or RECORD)
Direction of transmission. (INPUT, OUTPUT or UPDATE)
Physical environment of the file.(Record size, blksize etc..)
DCL INVEN FILE INPUT STREAM ENV (options).
It specifies that the identifier being declared is a file.
It can be implied if other file attributes are present in the DECLARE that enable the compiler to deduce the file attribute. e,g,
DCL BILLING INPUT STREAM ENV(F BLKSIZE(150));
One of these attributes must be specified either in the declare statement or in the open statement.
INPUT is the default attribute unless the file has the PRINT attribute.
It specifies that data items are accessed by GET or PUT statements that they are continuous stream. There are three forms of stream.
LIST Directed GET LIST, PUT LIST
EDIT Directed GET EDIT, PUT EDIT
DATA directed GET DATA, PUT DATA
Opposite of stream is record. If neither is not specified STREAM is assumed
It can be omitted if equivalent information is given in the JCL.
The options applicable to STREAM files are
ENV(F BLKSIZE(80)) Specifies
Record type is fixed
Each record is 80 byte long
Added for stream files associated with a printer.
Applies only to files with STREAM and OUTPUT attributes.
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.
DEFAULT or PREDEFINED FILES
SYSIN is the default standard input file.
SYSPRINT is the default standard output file.
GET LIST(A,B) is equal to GET FILE(SYSIN) LIST(A,B)
PUT LIST(A,B) is equal to PUT FILE(SYSPRINT) LIST(A,B)
SYSIN and SYSPRINT file names and their attributes need not be declared for IBM implementations. The default attributes are:
SYSIN FILE STREAM INPUT ENV(F BLKSIZE(80))
SYSPRINT FILE STREAM OUTPUT PRINT ENV(V BLKSIZE(129))