To Calulate length of each record length



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

To Calulate length of each record length

Postby mahua mitra » Tue Mar 30, 2010 10:00 pm

My requirement is that I need to calculate the length of each record in a file. The file is a variable length file. Then the lenth of each record has to be written in a different file.
How can I calculate the length of each record of a variable file through cobol.

Thanks
mahua mitra
 
Posts: 1
Joined: Tue Mar 30, 2010 9:54 pm
Has thanked: 0 time
Been thanked: 0 time

Re: To Calulate length of each record length

 

Re: To Calulate length of each record length

Postby Robert Sample » Tue Mar 30, 2010 10:36 pm

There is no need to calculate anything, assuming you are using a reasonably recent version of COBOL. Find your COBOL Language Reference manual and look up RECORD IS VARYING in the FILE SECTION. with this clause, you can specify a variable that will contain the length of each record as it is read. The only caveat is that you need to set the variable to the length of the record before doing a WRITE if you use the clause on an output file.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post