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

join on 3 tables using inner join.

Former Member
0 Likes
18,190

Hi friends can one one correct the below code and send me back.

its showing some error.

SELECT a~matnr

a~werks

b~maktx

c~prctr

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FOR ALL ENTRIES IN itab

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

WHERE a~matnr = itab-matnr

and werks = itab-werks.

1 ACCEPTED SOLUTION
Read only

former_member745780
Active Participant
0 Likes
10,392

Hello

try this


SELECT a~matnr
a~werks
b~maktx
c~prctr
c~bklas
C~stprs
c~peinh
INTO TABLE it_detail
FOR ALL ENTRIES IN itab
FROM marc AS a INNER JOIN makt AS b
ON a~matnr = b~matnr
inner join mbew AS c
ON b~matnr = c~matnr
WHERE a~matnr = itab-matnr
and werks = itab-werks.

11 REPLIES 11
Read only

former_member745780
Active Participant
0 Likes
10,393

Hello

try this


SELECT a~matnr
a~werks
b~maktx
c~prctr
c~bklas
C~stprs
c~peinh
INTO TABLE it_detail
FOR ALL ENTRIES IN itab
FROM marc AS a INNER JOIN makt AS b
ON a~matnr = b~matnr
inner join mbew AS c
ON b~matnr = c~matnr
WHERE a~matnr = itab-matnr
and werks = itab-werks.

Read only

0 Likes
10,392

anirudh check that code and send it once again

Read only

0 Likes
10,392

add this for compare b and c

ON b~matnr = c~matnr

hope this will help you

otherwise let me know the error.

and check your where clause

Thanks

Anirudh

Read only

Former Member
0 Likes
10,392

Hi,

Try this.

SELECT a~matnr

a~werks

b~maktx

c~prctr

c~bklas

C~stprs " c is in CAPS change it

c~peinh

INTO TABLE it_detail

FOR ALL ENTRIES IN itab

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

<give the field to compare in table b and c using ON condition>

WHERE a~matnr = itab-matnr

and werks = itab-werks.

Sharin.

Read only

Former Member
0 Likes
10,392

Hi,

Pls find the below piece of code.

begin of it_detail occurs 0,

matnr like mara-matnr,

werks like marc-werks,

prctr like marc-prctr,

maktx like makt-maktx,

bklas like mbew-bklas,

stprs like mbew-stprs,

peinh like mbew-peinh,

end of it_detail.

SELECT a~matnr

a~werks

a~prctr

b~maktx

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

on amatnr = cmatnr

FOR ALL ENTRIES IN itab

WHERE a~matnr = itab-matnr

and a~werks = itab-werks.

if it is not working, pls send me the error message that you are getting.

Thanks,

Sreeram.

Edited by: Sreeram Prasad on Aug 19, 2008 5:07 PM

Edited by: Sreeram Prasad on Aug 19, 2008 5:12 PM

Read only

former_member541575
Participant
0 Likes
10,392

hi

you can try this

SELECT a~matnr

a~werks

b~maktx

c~prctr

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FOR ALL ENTRIES IN itab

FROM marc

INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

ON amatnr = cmatnr

WHERE a~matnr = itab-matnr

and werks = itab-werks.

u can take help of this

SELECT ekko~ebeln

ekko~ekorg

ekko~aedat

ekko~lifnr

lfa1~name1

ekpo~ebelp

ekpo~matnr

ekpo~werks

ekpo~txz01

ekpo~menge

INTO TABLE i_ekko

FROM ekko

INNER JOIN ekpo ON ekkoebeln = ekpoebeln

INNER JOIN lfa1 ON ekkolifnr = lfa1lifnr

WHERE ekko~ekorg IN s_ekorg AND

ekko~ebeln IN s_ebeln AND

ekko~aedat IN s_aedat.

Regards

Atul

Read only

Former Member
0 Likes
10,392

Hi ,

Try this .

first please check whether the table ITAB has entries in it. If there are no entries , this select will fail.

if not itab[] is initial.

SELECT a~matnr

a~werks

b~maktx

c~prctr

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FOR ALL ENTRIES IN itab

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

on bmatnr = cmatnr

WHERE a~matnr = itab-matnr

and a~werks = itab-werks.

endif.

Regards,

Chitra

Read only

Former Member
0 Likes
10,392

Hi ,

You can try the following code.

select a~matnr

a~werks

b~maktx

c~prctr

c~bklas

c~stprs

c~pein

INTO TABLE IT_DETAIL

FOR ALL ENTRIES IN IT_TAB

FROM MARC AS a INNER JOIN MAKT AS b

ON aMATNR = bMATNR

INNER JOIN MBEW AS c

ON aMATNR = cMATNR

WHERE amatnr = it_tabmatnr

and

werks = it_tab-werks .

This query is going to fetch the correct data.Because we are filtering the data based on the MATNR(material number) to the maximum extent .

Regards

Navy

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
10,392

hi

Try to do like this...

SELECT a~matnr

a~werks

b~maktx

c~prctr

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FOR ALL ENTRIES IN itab

FROM ( (marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr )

inner join mbew AS c )

WHERE a~matnr = itab-matnr

and werks = itab-werks.

With Regards.

Always Learner

Read only

Former Member
0 Likes
10,392

Hi Priyanka,

1]You dont have field by name prctr in MBEW Table please correct this first

2]When you are declaring WERKS field in Internal Table declare this of type WERKS_D

3] Add BMATNR = CMATNR in your join statement as shown below.

SELECT a~matnr

a~werks

b~maktx

c~bklas

c~stprs

c~peinh

INTO TABLE it_detail

FROM marc AS a

INNER JOIN makt AS b

ON amatnr eq bmatnr

inner join mbew AS c

on bmatnr eq cmatnr

FOR ALL ENTRIES IN itab

WHERE a~matnr eq itab-matnr

and a~werks eq itab-werks.

Thanks

Sudharshan

Read only

Former Member
0 Likes
10,392

Hi,

Pls find the below piece of code.

begin of it_detail occurs 0,

matnr like mara-matnr,

werks like marc-werks,

prctr like marc-prctr,

maktx like makt-maktx,

bklas like mbew-bklas,

stprs like mbew-stprs,

peinh like mbew-peinh,

end of it_detail.

SELECT a~matnr

a~werks

a~prctr

b~maktx

c~bklas

C~stprs

c~peinh

INTO TABLE it_detail

FROM marc AS a INNER JOIN makt AS b

ON amatnr = bmatnr

inner join mbew AS c

on amatnr = cmatnr

FOR ALL ENTRIES IN itab

WHERE a~matnr = itab-matnr

and a~werks = itab-werks.