the inner loop runs until %eof. Then you write to the subfile. The reade that follows the write to the subfile will return %eof because the cursor into the file has not been reset.
write sfl01
exgdat reade curexg
use SETGT and then READ to read to the EXGDAT of the next set of currency rate records.
write sfl01
exgdat setgt curexg
read curexg
to debug the problem where you are not reading the records you expect, try to write the results of every read to a print file. That way you have something you can look at after the program runs. Might help understand what was read and why.
FQSYSPRT o f 132 printer OflInd(*inOf)
d lineData s 132a
if *inof = '1' ;
except newPage ;
endif ;
lineData = %eof + ' ' + exgcod + ' ' +
%editc(exgrat:'J') +
' ' + %char(exgdat:*iso) ;
except detail ;
OQsysprt E NewPage 1
O LineData 132
O E Detail 1
O LineData 132