Application Development and Automation 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: 
Read only

About accessing IDoc structure

former_member611006
Active Participant
0 Likes
913

Hi Experts,

I'm creating a SHPMNT04-IDoc for deliveries. For each position in the delivery, I want to modify the position no. (E1EDL24-POSNR) when the position type (E1EDL26-PSTYV) is eq "ZHUM".

I 'm editing a segment like this:

DESCRIBE TABLE idoc_data  LINES lc_va_line.
READ TABLE idoc_data      INDEX lc_va_line.
MOVE idoc_data-sdata      TO lc_wa_e1edl24.
......
MOVE lc_wa_e1edl24        TO idoc_data-sdata.
MODIFY idoc_data          INDEX lc_va_line.
CLEAR idoc_data.

... but how can I test a value in the substructure E1EDL26 and modify a value in the upper-structure E1EDL24 ?

Thanks a lot for support.

Regards,

David.

1 ACCEPTED SOLUTION
Read only

alex_m
Active Contributor
0 Likes
829

I hope you want help on the coding to modify the segment E1EDL24-POSNR then do like this..

Loop at Idoc_data.

If idoc_data-segnam = 'E1EDL24'.

READ TABLE idoc_data with key segnam = 'E1EDL26'.

if sy-subrc = 0.

MOVE idoc_data-sdata TO lc_wa_e1edl26.

if lc_wa_e1edl26-pstyv = 'zhum'.

modify the sgement E1EDL24

endif.

endif.

endif.

endloop.

5 REPLIES 5
Read only

alex_m
Active Contributor
0 Likes
830

I hope you want help on the coding to modify the segment E1EDL24-POSNR then do like this..

Loop at Idoc_data.

If idoc_data-segnam = 'E1EDL24'.

READ TABLE idoc_data with key segnam = 'E1EDL26'.

if sy-subrc = 0.

MOVE idoc_data-sdata TO lc_wa_e1edl26.

if lc_wa_e1edl26-pstyv = 'zhum'.

modify the sgement E1EDL24

endif.

endif.

endif.

endloop.

Read only

0 Likes
829

Hi guys,

thank you for your answers.

@ Alexander :

I used your coding like this:

IF segment_name EQ 'E1EDL24'.
        DESCRIBE TABLE idoc_data  LINES lc_va_line.
        READ TABLE idoc_data      INDEX lc_va_line.
        MOVE idoc_data-sdata       TO    lc_wa_e1edl24.
        READ TABLE      idoc_data WITH  KEY segnam = 'E1EDL26'.
        IF sy-subrc = 0.
          MOVE idoc_data-sdata TO       lc_wa_e1edl26.
          IF lc_wa_e1edl26-pstyv =      'ZHUM'.
             lc_wa_e1edl24-posnr = lc_wa_e1edl24-posnr + 9010.
          ENDIF.
        ENDIF.
        MOVE lc_wa_e1edl24    TO    idoc_data-sdata.
        MODIFY idoc_data          INDEX lc_va_line.
        CLEAR idoc_data.
      ENDIF.

... I think there is a problem when I update de internal table "idoc_data" with "MOVE lc_wa_e1edl24 TO idoc_data-sdata" because after reading the E1EDL26 segment, I've got another index. What do you think ?

Regards,

David

Read only

Former Member
0 Likes
829

save the index (sy-index) for the E1EDL24 access !

Read only

alex_m
Active Contributor
0 Likes
829

As Gordon said, use one variable and assign the index value for the E1EDL24 read and use that in modify statement.

Read only

Former Member
0 Likes
829

hi,

there is an easier way to solve this.


data: lc_wa_e1edl24 type e1edl24.
data: lc_wa_e1edl26 type e1edl26.
field-symbold: <idoc_data> type edidd.

loop at idoc_data assigning <idoc_data>.

case <idoc_data>-segnam.


when 'E1EDL24'
lc_wa_e1edl24 = <idoc_data>-sdata.
... do your changes (remember posnr)
<idoc_data>-sdata = lc_wa_e1edl24.    "you don´t need to modify idoc_data.
when 'E1EDL26'.
lc_wa_e1edl26 = <idoc_data>-sdata.
... do your chnages. (use posnr)
<idoc_data>-sdata = lc_wa_e1edl26.    "you don´t need to modify idoc_Data


endcase.




endloop.

i think this should help you !

Edited by: Gordon Breuer on Aug 6, 2009 11:31 AM