Quick 'n Dirty Unpacking of COMP-3?

docdwarf_at_panix.com
Date: 05/07/04


Date: 7 May 2004 07:51:56 -0400


So... there's this file, see, that all-of-a-sudden someone Absolutely Must
Have ftp'd from the mainframe to a Unix box... not too often, only every
week or so. LRECL=6000 and it contains COMP-3 fields... lots of COMP-3
fields... when I pull up the layout in ISPF editor and f COMP-3 all it
tells me there are 1,067 hits.

(Further research revealed no other type of non-DISPLAY numerics, no COMP
or COMP-n or BINARY or POINTERs)

First thing I do is look for FileAid jobs I have that do something
similar... and then I remember that there's no FileAid on the system.

Next thing I do is check the almost-FileAid they have, something called
MAX... it can reformat based on COBOL layouts. I take a copy of the
file's layout, edit it to c 'COMP-3' '' all, put it into a program
skeleton and compile it to determine the new LRECL (9116), code up a
jobstream to let 'er rip... and it runs...

... and it runs...

... and it runs some more, after three hours of wall-time it blows up on a
B37 (space error)... whoopsie... didn't code SPACE= to be a bit more than
a third larger. (The output I got - gotta love ,CATLG,CATLG - looked
pretty good for what got through.) While it is running I figure, just for
laffs, to code some COBOL using the two layouts I already have...
something really complex, like:

OPEN INPUT INFILE OUTPUT OUTFILE.
PERFORM UNTIL NO-MORE-INPUT
    READ INFILE INTO WK-INREC
        AT END SET NO-MORE-INPUT TO TRUE
        NOT AT END
            ADD 1 TO INREC-CTR
            MOVE CORR WK-INREC TO WK-OUTREC
            WRITE OUTREC FROM WK-OUTREC
            ADD 1 TO OUTREC-CTR
    END-READ
END-PERFORM.
DISPLAY 'INRECS READ ', INREC-CTR.
DISPLAY 'OUTRECS WRIT ', OUTREC-CTR.
CLOSE INFILE OUTFILE.
GOBACK.

(Notice the blithe use of MOVE CORR... kids, don't try this at home!)

... and I cobb together a jobstream, and wing it off...

... and Baby's not Happy, she blows up on record 1 with a S0C7
(non-numeric data exception)... so there's at least one record with
garbage data in it...

... and where there's one there's often a chance for more.

So... while the MAX job is running again, with a larger SPACE= for the
outfile I figured I'd ask if there is, once again, a Really Obvious
Solution that I'm missing... in this case one that would obviate the need
for me to code over a thousand IF FLD1 NOT NUMERIC MOVE +0 TO FLD1 (and
similar) statements.

Thanks for your time.

DD