Skip to Content
1

Finding correct index to insert new segment in IDOC data

Oct 20, 2016 at 12:56 PM

268

avatar image

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Jelena Perfiljeva
Oct 21, 2016 at 08:27 PM
1

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.

Share
10 |10000 characters needed characters left characters exceeded
Tomas Buryanek Oct 21, 2016 at 01:54 PM
0

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)?

Share
10 |10000 characters needed characters left characters exceeded