Difference between FILE Declarations



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Difference between FILE Declarations

Postby vikram G » Tue Apr 19, 2011 9:33 pm

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.
vikram G
 
Posts: 9
Joined: Fri Dec 17, 2010 9:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Difference between FILE Declarations

 

Re: FILES

Postby MrSpock » Tue Apr 19, 2011 9:44 pm

Is there supposed to be a question here?
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: FILES

Postby vikram G » Tue Apr 19, 2011 9:48 pm

hI

My question is for what use in file section Record, Block, Label, Data records are used...??
vikram G
 
Posts: 9
Joined: Fri Dec 17, 2010 9:21 pm
Has thanked: 0 time
Been thanked: 0 time

Re: FILES

Postby Robert Sample » Tue Apr 19, 2011 11:03 pm

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?
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Difference between FILE Declarations

Postby vinod_rana » Sun Apr 24, 2011 7:19 pm

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.
vinod_rana
 
Posts: 8
Joined: Thu Apr 21, 2011 12:58 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post