‎2009 Jul 30 11:41 AM
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
‎2009 Jul 30 11:52 AM
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.
‎2009 Jul 30 11:52 AM
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.
‎2009 Jul 30 12:00 PM
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.