Since the task is for Cobol practice, do everything in Cobol except for a simple "sort" of each of your input files before the matching.
Here is one way to "get rid" of your "-" in Cobol.
05 af-first-part pic xx.
05 af-dash pic x.
05 af-last-part pic x(4).
05 anf-first-part pic xx.
05 anf-last-part pic x(4).
MOVE af-first-part TO anf-first-part
MOVE af-last-part TO anf-last-part
There is no problem in sorting with the "-" in the field, as it is always present and always in the same place, so it will not affect the sort order into your program even if it not with the "-" on both files.