Page 1 of 1

To Calulate length of each record length

PostPosted: Tue Mar 30, 2010 10:00 pm
by mahua mitra
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

Re: To Calulate length of each record length

PostPosted: Tue Mar 30, 2010 10:36 pm
by Robert Sample
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.