Insert a new segment into block of repeating segments

This question comes from time to time in support inquiries.

What if we have to add another comment, NTE segment, in 3rd position in block of 11 NTE  segments?

Let’s take a message that has more than 4 ‘Orders’, and 4th ‘Order’ has more than 3 ‘Results’; and 3rd ‘Result’ has 11 comments (NTE segments.)

 for j = #Out.Order[4].Result[3].NTE, 3, -1 do
      Out.Order[4].Result[3].NTE[j+1]=Out.Order[4].Result[3].NTE[j]
      Out.Order[4].Result[3].NTE[j+1][1]=j+1   
   end

 Out.Order[4].Result[3].NTE[3][3][1]='New comment'

The steps of processing can be clearly seen on below screen capture:

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.