2006 Aug 29 9:03 PM
how to join 5 tables kna1,knvv,knb1,knvi and knvp all of customer master .I appreciate your response
Hi,
Write the select query based on the following psudo code.
Add your new fields in Where condition as well on extraction fields and join condition as per your requirement.
select a~<field1>
b~<field2>
c~<field3>
d~<field4>
e~<field5>
from kna1 AS a
inner join knvv as b on akunnr = bkunnr
inner join knb1 as c on akunnr = ckunnr
inner join knvi as d on akunnr = dkunnr
inner join knvp as e on akunnr = ekunnr
where a~kunnr in s_kunnr AND
<cond2> OR
etc,..
If you need more detail let me know your complete requirements.
thanks,
BtReddy
Message was edited by: B t
2006 Aug 29 9:13 PM
Hi Priya,
1) Join on more than 2 tables is always leads to low performance.
2) Its always better to perfrom a FOR ALL ENTRIES option.
3) Have a check whether internal table is empty or not before performing a FOR ALL ENTRIES option.
The below code has join upto 3 levels. This may help you in building join upto 5 levels.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT ccarrname pconnid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON pcarrid = ccarrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON fcarrid = pcarrid
AND fconnid = pconnid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Thanks,
Vinay
2006 Aug 29 9:15 PM
Hi,
Write the select query based on the following psudo code.
Add your new fields in Where condition as well on extraction fields and join condition as per your requirement.
select a~<field1>
b~<field2>
c~<field3>
d~<field4>
e~<field5>
from kna1 AS a
inner join knvv as b on akunnr = bkunnr
inner join knb1 as c on akunnr = ckunnr
inner join knvi as d on akunnr = dkunnr
inner join knvp as e on akunnr = ekunnr
where a~kunnr in s_kunnr AND
<cond2> OR
etc,..
If you need more detail let me know your complete requirements.
thanks,
BtReddy
Message was edited by: B t
2006 Aug 29 9:16 PM
Hi Priyanka,
Try this way.
select af1 bf2 cf3 DF4 E~F5
into table itab
from kna1 as a inner join knvv as b on af1 = bf1
inner join knb1 as c on af1 = cf1
inner join knvi as d on af1 = df1
inner join knvp as e on af1 = ef1
where a~f1 = parameter.
Regards,
Vivek
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |