I'm not sure what you've identified the length of, but although you've applied code to get an answer, if you are reading an input three times you may as well write a program to do it.
However, what you seem to want can be done in one pass of the data. Have a look at what JFY with SHIFT=RIGHT can do. It can slam the contents of your field to the right, so that the last two bytes of the field are in a fixed position, which you can then use in BUILD.
You can't use anything directly from a field to indicate information for position/length in the sort control cards themselves.
Joined: 14 Mar 2007 Posts: 8594 Location: Back in jolly old England
Your code looks as though you are still doing two passes of the data.
I think that Bill was hinting at something like building an INREC record where the right shifted field is added to the end of the record, and an OUTREC BUILD to select the required fields from the layout created by the INREC BUILD.
I have assumed that the RECFM=FB as you are using position 1 as the start of your data.
No mainframe access at the moment so can't test the theory, but it should get this done in a single pass of the data.
That should give you the same output, with only reading the data once.
However, you don't need PARSE, as the fields are in fixed position.
You can have multiple IFTHEN=(WHEN=INIT which allow you to use multiple functions in INREC (or OUTREC or OUTFIL), You can use OVERLAY to add a new temporary field to a record, then BUILD to make you final output. Unless you need column-numbers on a BUILD, it is easier to understand and maintain if you don't use them.