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: 

Using nested Joins in abap prog

Former Member
0 Kudos
711

Hi All,

please help me out in using nested joins in abap progrmaming. I dont know about joins in abap.specially in case of outer join.

I have 5 internal tables.. mara ,marc, mvke,mbew,ampl. am using a select query with certain fields from all these tables.

I need to disply all the materials of a mara for a particular date irrespective of the values in fields of other tables.

Even if that materail is not present in other table for certain condtion ,that material should get displyed with all other fields showing null value..

6 REPLIES 6

Former Member
0 Kudos
101

Hi,

Use for all entries rather joins.

Tks,

Krishna..

Former Member
0 Kudos
101

HI Suruti

Write Join in any report and press f1 on it. You will get the detail and Syntax.

Regards

Aditya

Former Member
0 Kudos
101

hi,

Its better not to use joins for 5 tables.

try for all entries.

rgds,

SG

rthoodi
Active Participant
0 Kudos
101

Hi,

for better performance try for all entries like this.

select matnr

from mara

into table it_mara

where matnr in s_matnr.

if not it_mara is initial..

select matnr

werks

from marc

into table it_marc

for all entries in it_mara

where matnr EQ it_mara-matnr.

endif.

Thanks

RK

Edited by: RK on Nov 14, 2008 10:35 AM

0 Kudos
101

Hi,

I think a better option is to create a view of all 5 tables in DDIC.

You can use the view in se38 to create internal tables just like you do using tables.

thanks nd regards

Arjun

Former Member
0 Kudos
101

Hi RK,

the code am using is of the same way...but my problem was with the joins..in the select query am using nested join combining inner and outer join.. but i could not able to display all the materials of mara of a particular date..

The code looks like this..

SELECT <some fields.......>

INTO TABLE i_materials

FROM ( marc AS b

INNER JOIN mara AS a ON amatnr = bmatnr

INNER JOIN mvke AS c ON cmatnr = amatnr

INNER JOIN ampl AS g ON gbmatn = amatnr

LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr

AND dbwkey = bwerks )

WHERE a~matnr IN s_matnr AND .................

Else

SELECT <some fields.......>

INTO TABLE i_materials

FROM ( marc AS b

INNER JOIN mara AS a ON amatnr = bmatnr

INNER JOIN mvke AS c ON cmatnr = amatnr

INNER JOIN ampl AS g ON gbmatn = amatnr

LEFT OUTER JOIN mbew AS d ON dmatnr = bmatnr

AND dbwkey = bwerks )

FOR ALL ENTRIES IN i_mara

WHERE a~matnr = i_mara-matnr AND ............