Page 1 of 1

variable record length file

PostPosted: Wed Sep 08, 2010 12:52 pm
by p kavitha
hi,


can any body explain how the variable record length file can be specified in file control section :?: :?: :?: .


Thanks and regards,
kavitha

Re: variable record length file

PostPosted: Wed Sep 08, 2010 2:55 pm
by Robert Sample
The FILE-CONTROL paragraph associates the COBOL name for the file with the external name (DD name) of the file. There is absolutely nothing in FILE-CONTROL to indicate that a file has variable length records -- this is determined in the FILE SECTION of DATA DIVISION.

Re: variable record length file

PostPosted: Wed Sep 08, 2010 5:23 pm
by p kavitha
Hi,

thanks for replay .then in file section what we want to specify and how can COBOL program recognize that either fixed length or variable length file is using.

Re: variable record length file

PostPosted: Wed Sep 08, 2010 5:43 pm
by Robert Sample
There are several ways that COBOL can determine a file has variable length records from the FD description in the FILE SECTION:

1. RECORDING MODE V
2. RECORD CONTAINS clause with minimum and maximum record lengths (and these values are different)
3. Multiple 01 variables in the FD with different lengths
4. At least one 01 variable in the FD that has OCCURS DEPENDING ON

Re: variable record length file

PostPosted: Wed Sep 08, 2010 5:55 pm
by p kavitha
Hi,


'RECORD CONTAINS clause with minimum and maximum record lengths (and these values are different)'

according to this sentence i want to define two 01 variables in file section then while reading the record how can we specify into which variable the values must move. and explain the situation if the record length is in between minimum and maximum.

reading the record means 'read input-file into variable'.

Re: variable record length file

PostPosted: Wed Sep 08, 2010 6:19 pm
by Robert Sample
If you have multiple 01 variables in the FD, when you do a READ command they ALL are loaded with the data read from the file -- there is an implied REDEFINES clause for each so you're really only describing one record area -- just in multiple ways.

RECORD CONTAINS (or RECORD IS VARYING -- they're formats 2 and 3 of the RECORD clause in the Language Reference manual) has nothing to do with multiple 01 variables. You seem to be confusing concepts here.

I strongly recommend you go to IBM's web site, find the COBOL Language Reference manual, and read every page of every subsection of section 5.2 on the file description entries -- this will clarify your understanding of how COBOL deals with files.

Re: variable record length file

PostPosted: Thu Sep 09, 2010 12:09 am
by dick scherrer
Hello,

Do you have something that needs a variable file or is this a solution in search of a requirement?