‎2006 Jul 19 4:34 PM
guys!!! how can we join two fields each of three tables using INNER JOIN command?
like 2 fields each of MARA MARC MARD INTO one table using INNER JOIN command...
Regards,
ajit.
‎2006 Jul 19 4:39 PM
This can be done simply like this.
data: begin of itab occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
werks type marc-werks,
dispo type marc-dispo,
lgort type mard-lgort,
labst type mard-labst,
end of itab.
select mara~matnr mara~mtart marc~werks marc~dispo
mard~lgort mard~labst
into table itab
from mara
inner join marc
on mara~matnr = marc~matnr
inner join mard
on marc~matnr = mard~matnr
and marc~werks = mard~werks
up to 10 rows.
Regards,
Rich Heilman
PS.
Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
Spread the wor(l)d!
‎2006 Jul 19 4:40 PM
SELECT a~matnr b~werks c~lgort
into table itab from mara as a inner join marc as b inner join mard as c
on a~matnr = b~matnr
on b~matnr = c~matnr.
‎2006 Jul 19 4:40 PM
SELECT MARA~FIELD MARC~FIELD MARD~FIELD
INTO CORRESPONDING FIELDS OF TABLE
FROM MARA
INNER JOIN MARC
ON MARA~MATNR = MARC~MATNR
AND MARA~XXX = MARC~XXX
INNER JOIN ON MARD
ON MARA~MATNR = MARD~MATNR
AND MARA~YYY = MARD~YYY
Regards,
Ravi
Note : Please mark all the helpful answers
‎2006 Jul 20 3:53 AM
SORRY TO SAY!!! but none of your statements worked guyz!!!
‎2006 Jul 20 4:06 AM
Hi Ziden,
Go through the below sample code,
DATA: BEGIN OF wa,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
bookid TYPE sbook-bookid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY carrid connid fldate bookid.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
LOOP AT itab INTO wa.
AT NEW fldate.
WRITE: / wa-carrid, wa-connid, wa-fldate.
ENDAT.
WRITE / wa-bookid.
ENDLOOP.
Reward points for helpful answers.
Regards,
Azaz Ali.
‎2006 Jul 20 4:13 AM
doesnot worked means what error u r getting.
all the stements above mentioned are correct.
what error u r facing and if u want some thing more, try to explain more clearly.
SELECT AMATNR AMTART BWERKS BLVORM CLGORT CLABST
FROM MARA AS A INNER JOIN MARC AS B ON AMATNR = BMATNR
INNER JOIN MARD AS C ON CWERKS = DWERKS INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE <CONDITION>.
‎2006 Jul 20 4:14 AM
hello rich!!!
Rn't u using aliaz names in your statement??
If using , can we use table name itself as aliaz names???
n moreover!!! dont we need to write
<table name> AS <aliaz name> in d statement
it wud be thankful if u clear all my doubts as u've written d statement.
and cud u plz use CORRESPONDING FIELDS OF in ya statement n write d stmt again...??
Regards,
ajit.
‎2006 Jul 20 4:19 AM
ALIAS STATEMENTS are not compulsory and also into corresponding fields is also not compulsory, if u retrive the fields in order.
what ever RICH written is excatly right. there would be no syntax error in that if u retrieve fields in order.
‎2006 Jul 20 6:08 AM
‎2006 Jul 20 6:14 AM
select matnr into itab from
mara as a inner join marc as c
on aMATNR = cMATnr
innerjoin MARD as d
on aMATNR = dMATNR