Segregating a variable length file in to different files.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Gaurav ABN
Registered Member
Posts: 12
Joined: Mon Sep 29, 2014 11:45 am

Segregating a variable length file in to different files.

Post 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
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post 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.
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

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

Post 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.
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

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

Post 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.
Regards
Nic
Gaurav ABN
Registered Member
Posts: 12
Joined: Mon Sep 29, 2014 11:45 am

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

Post 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.
Gaurav ABN
Registered Member
Posts: 12
Joined: Mon Sep 29, 2014 11:45 am

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

Post 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.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”