First of all, you have to know that 4D Write Pro handles table pagination since V17R2. That means tables are not truncated anymore in page mode! They are automatically splitted in as many tables as needed without any loss.
There are also new possibilities to add columns and page breaks to split a table in two or more parts.
In both cases, the table will keep it’s unique ID.
But i understand in your case that’s not enough if you want insert a header on each page, so you need to detect the page breaks when they occur, right ?
As long as there is no way (yet) to manage rows (insert / delete / etc.) the most simple way to that is to make a copy of your document before you insert a row. Once this is done, insert your row and check the page number. If it has changed, rollback, add a header and go on…
We know this is a bit ugly, but consider this is a temporary situation and just a work around until dedicated commands comes out to manage rows (and cells…) in tables.
Note that if you want to use the same principe for paragraphs, it’s much more simple.
No need to memorise the full document! Just memorise the range before insertion, insert the text, check the page number. If it has changed, go back to the memorised range, insert (force) a page break, then go to the end of your document (after the last text has just been inserted) and go on !
Hope this helps.