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

COEP Access

Former Member
0 Likes
481

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
435

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. 

2 REPLIES 2
Read only

Former Member
0 Likes
436

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. 

Read only

Former Member
0 Likes
435

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