I need to retrieve details from two records if a value of both the record matches.
12345 CB CLAIM CLRD 01
12345 Invoice 2222 RR 02
13675 AB RTVNO CLRD 01
13675 Invoice 2908 XX 02
29876 DD DATAR OPEN 01
29876 Invoice 3452 ZS 02
The last two fields of the record may contain only 01 or 02
If position 1 to 5 of record having 01 as the last field matches with position 1 to 5 of record having 02 as the last field,
I need to move all the values from Record having 02 as last field and position 10 to 15 from the record having 01 as last field and to remove 02 from that record.
If position 1 to 5 of record having 01 as the last field matches with position 1 to 5 of record having 02 as the last field
All of the records you show in your example satisfy this condition. Is that always true? Will you always have an 01 and 02 pair of records for each key in order? Or are there other variations such as an 01 without an 02, or an 02 without an 01 or something else?
Please show a better example of your input records with ALL possible variations and what you expect for output. Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position of 01 and 02 in their respective records.