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: 

Problem in select query.

Former Member
0 Kudos

Hi ABAP gurus,

What is the problem with this query.

SELECT A~MATNR

A~MTART

B~werks

c~lgort

c~labst

INTO CORRESPONDING FIELDS OF IT_MAT

FROM mara AS A

left outer JOIN marc AS B ON aMATNR = BMATNR

left outer join mard as c on bmatnr = cmatnr and cwerks = bwerks

WHERE a~MATNR IN S_MATNR .

ENDSELECT.

It is giving me an error saying that table can be joined with max of one other table using left outer join

My requirement involves joining of these three tables this way to pick all those material numbers

which are in the material range s_matnr and have all werks related from marc and all storage locations

related to werks.

How to do it?

Nik

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Nik,

Left outer join does not work on three tables like this.

But You can write left outer join as follows....

mara left outer join marc on mara-matnr = marc-matnr

mara left outer join mard on mara-matnr = mard-matnr

or what best you can do is to make use of views.

Try doing it with above mentioned.

Regards,

suruchi

5 REPLIES 5

Former Member
0 Kudos

Hi Nik,

Left outer join does not work on three tables like this.

But You can write left outer join as follows....

mara left outer join marc on mara-matnr = marc-matnr

mara left outer join mard on mara-matnr = mard-matnr

or what best you can do is to make use of views.

Try doing it with above mentioned.

Regards,

suruchi

Former Member
0 Kudos

HI

GOOD

YOU CAN TRY YOUR LEFT OUTER JOIN LIKE THIS SYNTAX

SELECT...

...

FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>

<options>

-


DATA: BEGIN OF wa,

carrid TYPE scarr-carrid,

carrname TYPE scarr-carrname,

connid TYPE spfli-connid,

END OF wa,

itab LIKE SORTED TABLE OF wa

WITH NON-UNIQUE KEY carrid.

SELECT scarrid scarrname p~connid

INTO CORRESPONDING FIELDS OF TABLE itab

FROM scarr AS s

LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid AND

p~cityfrom = 'FRANKFURT'.

LOOP AT itab INTO wa.

WRITE: / wa-carrid, wa-carrname, wa-connid.

ENDLOOP.

THANKS

MRUTYUN

Former Member
0 Kudos

Nikhil,

Try using a simple join between the view MAWEV and table MARD.

You can try the outer join as well.

Regards,

Ravi

Former Member
0 Kudos

Hi Nikhil,

Try writing the select query using the brackets.

Regards,

Sameena

0 Kudos

Ya I could do it.

Thanx.

Nik