Thomas R Wyant_iii wrote:
> Kicking it up a level, are you just trying to convert the RMS indexed files
> to sequential files? If so, there are other ways to do it. Something like
That's sort of it, and for most of our systems, we can do exactly that. But
some files require special handling. What I am reading are data files that are
part of our Student Information System from a vendor called SCT Corp. To save
space, they "collapse" files before writing them to disk. For example, a
student demographic file will have a logical record length of 8000 characters
(and that is what I have to send to the data warehouse import job), but each
actual record that I read from disk will have something less than that. And I
can't just pad a record out to 8000 characters, because each record is composed
of a root and several "segments" and each segment can occur a number of times,
so for each segment I have to:
- read the segment counter (from the root segment)
- Multiply that by the number of characters in that segment
- extract that many characters from the record and append to output record
- Subtract the counter from the maximum number of segments that could occur
- pad the output record with (segment length * difference) characters
There are about 45 files that I have to do this with. So rather than writing
45 COBOL programs, I came up with a perl script that has something like this:
@sislist = qw(aa 949,939,897,1,941,110,16,943,98,5
then another 44 lines following);
which means I have a file called "aafile", the root segment is 949 characters,
then there is a segment counter at byte offset 939 describing a segment that is
897 characters long and can occur up to one time, then a counter at byte offset
941 that describes a segment that is 110 characters long and can occur up to 16
times, then at byte offset 943, there is a counter for a segment that is 98
characters long and can occur up to five times. Using that information, I have
an "exploder" routine that pads each segment to its logical length and write an
output record that matches the copy book.
My problem lies in the fact that some records in some files apparently have
packed decimal values that resemble line feeds (or carriage returns) and so
even though I may have a loop that will do a "print" 64 times, I look at the
file with an editor and see 84 lines. It was suggested that using syswrite
rather than print might get around that problem, and I am going to try that
next.
Thanks for the feedback...
Jim McCullars
U of Ala Huntsville