Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Select statement

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

Tags:
Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question