2008 Nov 14 9:25 AM
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..
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..
2008 Nov 14 9:29 AM
2008 Nov 14 9:30 AM
HI Suruti
Write Join in any report and press f1 on it. You will get the detail and Syntax.
Regards
Aditya
2008 Nov 14 9:30 AM
hi,
Its better not to use joins for 5 tables.
try for all entries.
rgds,
SG
2008 Nov 14 9:34 AM
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
2008 Nov 14 10:40 AM
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
2008 Nov 14 10:59 AM
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 ............
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |