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

Custom Segment - Idoc Code

Former Member
0 Likes
506

Hi All,

I am trying to fill a custom segment Z1XXXXXX which I added to the MATMAS05 idoc type.

I need to fill this custom segment data from a ZTABLE.

This table has multiple records for a single material.

Here's my code in the user exit. .

data: i_zxxxxxx type Z1XXXXXX,

t_ztable type table of ztable with header line,

w_ztable type ztable.

Loop at Idoc_data.

if idoc_data-segnam = 'Z1XXXXXX'.

move Idoc_data-sdata to i_zxxxxxx.

select * from ztable into t_ztable where matnr eq f_mara-matnr. "f_mara-matnr is an exporting parameter in the function module

loop at t_ztable into w_ztable.

move-corresponding w_ztable to i_zxxxxxx.

move i_zxxxxxx to Idoc_data-sdata.

endloop.

endif.

endloop.

Please let me know if I'm missing anything.

Thanks,

Meghna

1 ACCEPTED SOLUTION
Read only

alex_m
Active Contributor
0 Likes
408

Do the changes like below.

Loop at Idoc_data.

if idoc_data-segnam = 'Z1XXXXXX'.

move Idoc_data-sdata to i_zxxxxxx.

select * from ztable into t_ztable where matnr eq f_mara-matnr. "f_mara-matnr is an exporting parameter in the function module

loop at t_ztable into w_ztable.

MOVE Z1XXXXXX' TO idoc_data-segnam.

move-corresponding w_ztable to i_zxxxxxx.

move i_zxxxxxx to Idoc_data-sdata.

INSERT idoc_data INDEX (You mention the correct index)

endloop.

endif.

endloop.

This will update the multiple segments to the Idoc.

2 REPLIES 2
Read only

alex_m
Active Contributor
0 Likes
409

Do the changes like below.

Loop at Idoc_data.

if idoc_data-segnam = 'Z1XXXXXX'.

move Idoc_data-sdata to i_zxxxxxx.

select * from ztable into t_ztable where matnr eq f_mara-matnr. "f_mara-matnr is an exporting parameter in the function module

loop at t_ztable into w_ztable.

MOVE Z1XXXXXX' TO idoc_data-segnam.

move-corresponding w_ztable to i_zxxxxxx.

move i_zxxxxxx to Idoc_data-sdata.

INSERT idoc_data INDEX (You mention the correct index)

endloop.

endif.

endloop.

This will update the multiple segments to the Idoc.

Read only

Former Member
0 Likes
408

hi

check this code

select * from ztable into t_ztable where matnr eq f_mara-matnr. "f_mara-matnr is an exporting parameter in the function module

Loop at Idoc_data.

if idoc_data-segnam = 'Z1XXXXXX'.

move Idoc_data-sdata to i_zxxxxxx.

loop at t_ztable into w_ztable.

move-corresponding w_ztable to i_zxxxxxx.

move i_zxxxxxx to Idoc_data-sdata.

endloop.

endif.

endloop.