0 pts.
 Insert record in subfile
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

Answer Wiki:
I don't believe it can be done without building the subfile again. Maybe someone else has an idea but I would just rebuild the subfile.
Last Wiki Answer Submitted:  February 3, 2006  8:11 am  by  JBurelle   0 pts.
All Answer Wiki Contributors:  JBurelle   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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

 370 pts.