How to code insertion on a new receord between 2 existing recods in a subfile ?
I want to code something like a expand tree : I READC my subfile and when option code value is ... I want to add some records between current & next subfile record
Software/Hardware used:
ASKED:
February 3, 2006 4:01 AM
UPDATED:
February 3, 2006 9:51 AM
The way I would do it would be to use a Keyed User Index and a page-at-a-time (SFLSIZ = SFLPAG) sufile.
The first time I load the subfile I would write the records to a user space as well. If the user pages down then I would load the next page (overwriting the existing page) and add the records to the end of the User Index.
If the user inserts a record then I would load it into the User Index with an appropriate “key” and then reload the subfile starting with the currently top record.
If the user pages up then I would calculate how far back up the User Index I would have to go and reload the subfile from there.
Depending on how many records you expect to insert between subfile records then you may need to renumber the user index keys each time.
Hope it helps
Jonathan