Your problem, it seems to me, is the CHAR() functions in your WRITESEQ statement. WRITESEQ itself adds a line terminator - that's why you're getting two lines. All you need is
Actually I think I was not clear and you didnt get it. When the routine is called for the third time, the last register inserted is updated, and it happens every time the routine is called. In short, the file has always only two registers.
Even if I call it thousand of times.
Ex. If I call the routine for the fourth time, the last register - which was updated by the third execution - is updated again. Keeping only the number of two registers.
Again, try (or look at the source for) OpenSequentialFile routine - there's a link to it in my earlier post. You need to SEEK to end of file before using WRITESEQ to insert the new line.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.