It's not clear what you want to do. Please show an example of the records in your input file and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input files. Give the starting position, length and format of any relevant fields.