Application Development 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: 

select statement n joining condtion..

Former Member
0 Kudos

Hi Friends,

In a Report, I have the Material Numbers dispayed as of now. I have to select/display the rate(condition amount) for each Material Number that is on the list....

I have realized that I can relate the Mat. No with the Rate by using 3 tables....

1.MARA

2.A505

3.KONP.

I'm thinking to relate this rate(KONP-KBETR) with Mat No(MARA-MATNR) like this....

JOIN the MARA-MATNR with A505-MATNR and then A505-KNUMH with KONP-KNUMH and then retrieve KONP-KBETR...

but i dont know how to write the select and joining condition...

as of now... i have a INTERNAL TABLE :- i_matdata.

which contains the mat. no's

help me, plz...

thanks,

raj

2 REPLIES 2

Former Member
0 Kudos

THIS IS ONE SOLUTION

SELECT A~MATNR

B~KNUMH

INTO CORRESPONDING FIELDS OF TABLE I_TAB1

FROM MARA AS A INNER JOIN

A505 AS B ON

AMATNR = BMATNR

FOR ALL ENTRIES IN I_MATNR

WHERE A~MATNR = I_MATNR-MATNR.

SORT I_TAB1 BY KNUMH.

SELECT A~KNUMH

B~KBETR

INTO CORRESPONDING FIELDS OF TABLE I_TAB2

FROM A505 AS A INNER JOIN

KONP AS B ON

AKNUMH = BKNUMH

FOR ALL ENTRIES IN I_TAB1

WHERE A~KNUMH = I_TAB1-KNUMH.

LOOP AT I_TAB1.

READ TABLE I_TAB2 WITH KEY KNUMH = I_TAB1-KNUMH.

I_TAB3-MARNR = I_TAB1-MATNR.

I_TAB3-KBETR = I_TAB2-KBETR.

APPEND I_TAB3.

ENDLOOP.

former_member186741
Active Contributor
0 Kudos

My site doesn't have A505 with matnr and knumh but I found a similar one A550 so you could do something like this:

select maramatnr konpkbetr

from mara

join a550 on maramatnr = a550matnr

join konp on konpknumh = a550knumh

into corresponding fields of table i_rates

FOR ALL ENTRIES IN i_matdata

WHERE mara~MATNR = i_matdata-MATNR

.