‎2008 Dec 03 8:03 PM
Hi
i think i can post my query in more simpler way .
I want to replace all material here in same table with 20299 main materrial.
How to get main material .any object num for which kstar = 519000 in front of that is main material.
objnr kstar matnr
OR000000009726 510000 10043
OR000000009726 510000 10030
OR000000009726 510000 10025
OR000000009726 510000 10035
OR000000009726 519000 20299
OR000000009726 510000 10035
OR000000009726 519500 20299
OR000000009726 950145 20299
OR000000009726 950115 20299
Regards
Ivneet
‎2008 Dec 03 9:01 PM
check this code.but make sure you select all the KEY fields into internal table.
select objnr kstar matnr INTO table itab from coep
where <condition>.
SORT itab.
loop at itab into wa_itab where kstar NE '519000'.
v_index = sy-tabix.
read table itab into wa_itab2 where objnr = wa_itab-objnr
kstar = '519000'
BINARY SEARCH.
IF sy-subrc = 0.
wa_itab-matnr = wa_itab2-matnr.
modify itab from wa_itab Index v_index transporting matnr.
endif.
clear wa_itab,wa_itab1.
ENDLOOP.
modify coep from itab.
‎2008 Dec 03 9:01 PM
check this code.but make sure you select all the KEY fields into internal table.
select objnr kstar matnr INTO table itab from coep
where <condition>.
SORT itab.
loop at itab into wa_itab where kstar NE '519000'.
v_index = sy-tabix.
read table itab into wa_itab2 where objnr = wa_itab-objnr
kstar = '519000'
BINARY SEARCH.
IF sy-subrc = 0.
wa_itab-matnr = wa_itab2-matnr.
modify itab from wa_itab Index v_index transporting matnr.
endif.
clear wa_itab,wa_itab1.
ENDLOOP.
modify coep from itab.
‎2008 Dec 03 9:29 PM
I'd make really sure I knew what I was doing before I updated a standard SAP table like this. Particularly one as important as this one that must be kept in synch with other tables.
Rob