Page 1 of 1

Difference between FILE Declarations

PostPosted: Tue Apr 19, 2011 9:33 pm
by vikram G
I have given you some sample code, In 1st one in the file section the highlighted file given something as Record, Block, Label, Data record. What type of declaration is this.

In these days I have come across 2nd type of declaring files I have attached that too for your reference.

Given me the difference between both the declarations, once u understood you call me


1.

FILE-CONTROL.
SELECT OUTPUT-FILE ASSIGN TO FILEOUT1.

DATA DIVISION.

FILE SECTION.
FD OUTPUT-FILE
RECORD CONTAINS 80 CHARACTERS
BLOCK CONTAINS 0 RECORDS
LABEL RECORD IS STANDARD
DATA RECORD IS OUTPUT-RECORD.
01 OUTPUT-RECORD PIC X(80).

WORKING-STORAGE SECTION.


2.

FILE-CONTROL.
SELECT PLAN-CODES-FILE ASSIGN TO PLANMAS
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS IN-PLAN
FILE STATUS IS WS-PLAN-STATUS.
SELECT STATE-CODES-FILE ASSIGN TO STATE
ORGANIZATION IS INDEXED
ACCESS MODE IS RANDOM
RECORD KEY IS IN-STATE
FILE STATUS IS WS-STATE-STATUS.
DATA DIVISION.
FILE SECTION.
FD PLAN-CODES-FILE.
01 PLAN-REC.
05 IN-PLAN.
10 CV-CLASS PIC X(01).
10 BASE PIC X(03).
05 FILLER PIC X(01) VALUE SPACES.
FD STATE-CODES-FILE.
01 STATE-REC.
05 IN-STATE PIC X(02).
WORKING-STORAGE SECTION.

Re: FILES

PostPosted: Tue Apr 19, 2011 9:44 pm
by MrSpock
Is there supposed to be a question here?

Re: FILES

PostPosted: Tue Apr 19, 2011 9:48 pm
by vikram G
hI

My question is for what use in file section Record, Block, Label, Data records are used...??

Re: FILES

PostPosted: Tue Apr 19, 2011 11:03 pm
by Robert Sample
The label clause has declined in importance over the years. LABEL RECORDS STANDARD for files, LABEL RECORDS OMITTED for spool output is pretty much all that I've seen for quite a few years.

As the manual says, the DATA RECORDS clause is syntax checked but that's it -- not used any more.

To understand RECORD CONTAINS and BLOCK CONTAINS, you must first understand that the system has a specific order for acquiring information about a data set. The first reference will be the program. If some values are not supplied by the program, the system then checks the JCL. If some values are not supplied by the program or JCL, then the dataset itself is checked to supply the missing values. So if you specify RECORD CONTAINS or BLOCK CONTAINS, they will override anything you specify in the JCL. This allows the programmer better control in the code over the physical attributes of the file. If you specify RECORD CONTAINS 100 TO 200 CHARACTERS in your program, and the JCL has DCB=(RECFM=FB,LRECL=200,BLKSIZE=27800) -- guess what the data set gets defined as?

Re: Difference between FILE Declarations

PostPosted: Sun Apr 24, 2011 7:19 pm
by vinod_rana
Same explanation in different words

When we specify BLOCK CONTAINS 0 RECORDS ,the system will decide the optimum size for the file based on the device used for storing the file.
It can be understood as initialisation of a block.

Label records are usually created as the first and last records of a disk or tape to provide identifying information about the file on disk or tape. Labels are created on output files so that, when the same file is later read as input, the labels may be checked to ensure that the file being accessed is the correct one. Labels are created on output files and checked on input files. The COBOL compiler will supply the routine for writing labels on output files or for checking labels on input file if the entry LABEL RECORDS ARE STANDARD is included.

This LABEL RECORDS clause will result in the following :
1. For output files, the first record on disk or tape file will be created as a standard 80-position header label identifying the file to the system; similarly, the last record on the disk or tape will be created as a trailer label.
2. For input files, these labels will be computer-checked to ensure that the file being processed is the correct one.

The clause LABEL RECORDS ARE STANDARD is permitted for disk and tape files only. Devices such as printers do not use label records, since identifying information is unnecessary where data is visible to the human eye. The clause LABEL RECORDS ARE OMITTED is used for such files.