Hello,
I have not gone into the depth of the program, but from what I understood by quick read-through:
• You’re trying to create an interpreted COBOL copybook layout using the program you’ve shared - a layout that removes the gory details such as COMP, COMP-3, OCCURS etc.
• You’re doing this by reading an input dataset which contains some (and not all) elements of a native COBOL copybook
• There are checks built for these elements in the programs; the checks are not extensive
• All of this is being done by individually parsing each byte of text from the input dataset
• The way the data is being converted, it appears that the requirement is to get this entire level segregated copybook into a single row, which can later be converted to CSV
And the requirement now is to handle REDEFINES clause in this code.
To put across a point - for the heck of it - this is a very different requirement compared to the first post of this topic.
Having said that, all that you really need to handle a REDEF clause is understanding that the level redefining a certain field will ALWAYS be preceded by that field. Also when you do encounter the REDEF, why not continue processing the elements as-is like other earlier levels? How do you want to represent it?
Another question, why do all of this at all; what are we going to achieve by this exercise?
Why not use the predefined interpreters tools provided by File-Manager/File-Aid?
03 WS-REDEFINES-SET PIC X.
88 REDEFINES-SET VALUE 'Y'.
88 REDEFINES-NOT-SET VALUE 'Y'.