Re: COBOL is dynamic (depends)




HeyBub wrote:

Your solution is simple, compact, and easy to understand.

You're lucky to have a compiler that permits field names after an ODO. For
those of us with conforming compilers, your solution can't be used. If faced
with the same problem, I'd have to march an index down the input record
moving individual bytes to their prescribed destinations.

Or use reference notation, perhaps table driven:

01 Tspec PIC X(36) VALUE
"001004005002007049056004060049109001".
01 Uspec PIC X(36) VALUE
"001004005002007033040004044033077001".
etc
01 FieldSpec.
03 AStart PIC 999.
03 ALen PIC 999.
03 BStart PIC 999.
03 BLen PIC 999.
etc

MOVE TSpec TO FieldSpec
EVALUATE Data-In(CStart:1)
WHEN "U"
MOVE Uspec TO FieldSpec
WHEN OTHER
etc

MOVE Data-In(AStart:ALen) TO A
MOVE Data-In(BStart:BLen) TO B
etc

.