Skip to Content
1
Oct 20, 2016 at 12:56 PM

Finding correct index to insert new segment in IDOC data

1459 Views

Hello,

I am looking for best way for: how to find correct index to insert new segment into IDOC data (table of EDIDD) in user exit.

NOTE: I do not want change IDOC structure (WE30). I want to change data of specific IDOC.

Example

IDOC structure:

SEGMENT_TYPE  LEVEL    MANDATORY   MULTIPLE 
A             1        yes         no
|- B          2        no          yes
|- C          2        no          yes
   |- D       3        no          yes
|- E          2        no          yes

I want insert segment of type C and have ready IDOC data (EDIDD itab). Is there any trick to find correct index of itab? Because now I have to programmatically check:

  • find last segment of type C
  • IF exist, is there any subsegment D with index > than last segment of C... etc.

Hope you get idea, and this IDOC structure is only example. Real is more comlicated.