Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Finding correct index to insert new segment in IDOC data

Tomas_Buryanek
Active Contributor

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.

-- Tomas --
1 ACCEPTED SOLUTION

Jelena
Active Contributor

It depends on the specific IDoc and data in it. There is no simple, one-size-fits-all solution. Usually it's just trial and error. Run different IDocs through debugger and see if there is some pattern, etc. Lots of fun.

But you are correct that a custom segment is a more proper way to solve such issues.

2 REPLIES 2

Tomas_Buryanek
Active Contributor
0 Kudos

I resolved this with "workaround":

- created IDOC extension + new Z segment and inserted it into IDOC data in user exit

It is actually more proper way to solve this. But I am still interested if there is any way to solve original problem (inserting standard segment)?

-- Tomas --

Jelena
Active Contributor

It depends on the specific IDoc and data in it. There is no simple, one-size-fits-all solution. Usually it's just trial and error. Run different IDocs through debugger and see if there is some pattern, etc. Lots of fun.

But you are correct that a custom segment is a more proper way to solve such issues.