Actually, I'm doing it. Below is the generated macro code, which has no problems.
My code uses same idea: generate header, generate details, insert details, insert header - move to the next header... but why it fails on IDINVC assigment?
I know it looks stupid and annoying, sorry... Do you...