10-19-2007 9:03 PM
Hi gurus,
I have a condition where I have an internal table it_tab1 and it_tab1 has material number and price, now I passes this material no. into marc to get the plan information of the corresponding material and for this I have written this code:
select werks matnr from it_tab1 into table it_tab2
from marc
where matnr = it_tab1-matnr.
is this statment right?
and now I need to create one more internal table that will have three fields matnr, price and werks and now I need to join it_tab1 and it_tab2 to get price, matnr and werks in my third internal table.
can you please help me out to do this.
Thanks
Rajeev
Message was edited by:
Rajeev Gupta
10-19-2007 9:08 PM
It should be like this
select matnr werks from it_tab1 into table it_tab2
from marc
<b>for all entries in itab1</b>
where matnr = it_tab1-matnr.
Once you get data from MARC into ITAB2.
Sort ITAB1 by MATNR.
SORT ITAB2 BY MATNR.
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY MATNR = ITAB2-MATNR BINARY SEARCH.
IF SY-SUBRC EQ 0.
ITAB3-MATNR = ITAB1-MATNR.
ITAB3-WERKS = ITAB2-WERKS.
ITAB3-PRICE = ITAB1-PRICE.
APPEND ITAB3.
CLEAR ITAB3.
ENDIF.
ENDLOOP.
Hope this will help you.
ashish
10-19-2007 9:08 PM
It should be like this
select matnr werks from it_tab1 into table it_tab2
from marc
<b>for all entries in itab1</b>
where matnr = it_tab1-matnr.
Once you get data from MARC into ITAB2.
Sort ITAB1 by MATNR.
SORT ITAB2 BY MATNR.
LOOP AT ITAB2.
READ TABLE ITAB1 WITH KEY MATNR = ITAB2-MATNR BINARY SEARCH.
IF SY-SUBRC EQ 0.
ITAB3-MATNR = ITAB1-MATNR.
ITAB3-WERKS = ITAB2-WERKS.
ITAB3-PRICE = ITAB1-PRICE.
APPEND ITAB3.
CLEAR ITAB3.
ENDIF.
ENDLOOP.
Hope this will help you.
ashish
10-19-2007 9:09 PM
Hi,
Please try this.
select werks matnr
for all entries in it_tab1
into table it_tab2
from marc
where matnr = it_tab1-matnr.
loop at it_tab2.
read table it_tab1 with key matnr = it_tab2-matnr binary search.
if sy-subrc = 0.
it_tab3-matnr = it_tab2-matnr.
it_tab3-werks = it_tab2-werks.
it_tab3-price = it_tab1-price.
append it_tab3.
clear it_tab3.
endif.
endloop.
Regards,
Ferry Lianto
10-19-2007 9:11 PM
Hi
the select statement is wrong
if not it_tab1[] is initial.
select werks matnr into table it_tab2
from marc
for all entries of it_tab1
where matnr = it_tab1-matnr.
endif.
loop at it_tab1.
move it_tab1 records to it_tab3.
read table it_tab2 with key matnr = it_tab1-matnr.
move the records to it_tab3.
append it_tab3.
clear it_tab3.
endloop.
Regards
Anji