Generally you need something to tell you which OBX segments are to be NTE segments, then ITERATE over the OBX (usually a group). When you detect the OBX that needs to be an NTE do the COPYs to the NTE from the OBX. You will probably need to manage your own counter for the NTEs.
If you want to chat directly about this, email me directly.
Thanks,
Jim Kosloskey
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.