Page 1 of 1

Segregating a variable length file in to different files.

Posted: Tue Dec 22, 2015 2:47 pm
by Gaurav ABN
Hi,

For an input file which is variable block and is of length 214. This file can have four type of records. Length 80, 100, 200 and 210. My objective is to read this input file, which is apparently variable block file, and write the output files. There should be four different output files. How can I know the length of the file while reading? And how can I write 4 output files. Please help out.

Thanks

Re: Segregating a variable length file in to different files.

Posted: Tue Dec 22, 2015 6:37 pm
by Robert Sample
How can I know the length of the file while reading?
Read the Enterprise COBOL Language Reference manual for the RECORD CONTAINS DEPENDING ON clause.
And how can I write 4 output files.
1. Write 4 SELECT statements.
2. Write 4 FDs.
3. Open 4 files for output.
4. Write WRITE <record name> 4 times with <record name> being different each time (one per file).
5. Close 4 files.

You'll need EVALUATE or IF logic to determine which record to write each time.

Re: Segregating a variable length file in to different files.

Posted: Wed Dec 23, 2015 2:39 pm
by William Collins
Note, it is not the "length of the file" it is the record-length, an entirely different thing, whatever you think length of the file means.

Re: Segregating a variable length file in to different files.

Posted: Wed Dec 23, 2015 3:10 pm
by nicc
Does the record length depend upon type of record? Id there a record type identifier? If "yes" to both then write out according to record type - no need to know the length.

Re: Segregating a variable length file in to different files.

Posted: Mon Dec 28, 2015 12:38 pm
by Gaurav ABN
Robert Sample wrote:
How can I know the length of the file while reading?
Read the Enterprise COBOL Language Reference manual for the RECORD CONTAINS DEPENDING ON clause.
And how can I write 4 output files.
1. Write 4 SELECT statements.
2. Write 4 FDs.
3. Open 4 files for output.
4. Write WRITE <record name> 4 times with <record name> being different each time (one per file).
5. Close 4 files.

You'll need EVALUATE or IF logic to determine which record to write each time.
Thnaks Robert. Thanks for the hint, I will work with them.

Re: Segregating a variable length file in to different files.

Posted: Mon Dec 28, 2015 1:51 pm
by Gaurav ABN
nicc wrote:Does the record length depend upon type of record? Id there a record type identifier? If "yes" to both then write out according to record type - no need to know the length.
As of now there is no record type identifier. Length is the only record type identifier.