It looks as if your SCLR subr leaves field #RRNO with thevalue ‘5’. In your LOAD subr you test if #RRMO is equal to zero, which is not the case. Therefore you will do your looped writings with #RRNO = 5 constantly…
SCLR you have written the 5 records to the subfile.
You must Chain to each one and update.
you may want to MOVE *blank UPC before WRITE RECSFL
It looks to me like your Z-ADD 0 to I1 and then the ADD 1 I1 are intended to make your #RRNO field contain a continually incremented record number. But when you do the ADD I1 #RRNO, you’re not just moving the value of I1 to #RRNO, you’re adding it to #RRNO, so the values in #RRNO would be 1, 3, 6, etc.
Even with that said, you only execute the ADD I1 #RRNO once, since #RRNO won’t be zero the second time through the loop. Therefore, #RRNO will not get changed, and you’ll write record 1 a second time. That would give you a duplicate record error.