2007 Sep 06 1:19 PM
can anyone please tell me
shall we can use join in select statement for 4 tables.
for eg
i have 4 database tables BKPF,BSEG,SKAT,LFA1
I need to write select statement for above tables using join, is it possible
please help me.
Hi,
BESG is clustertable and JOINS doesnt work on Cluster tables.
Regards,
Naveen
2007 Sep 06 1:21 PM
hi,
yes u can use but its not recommended better u create an view and use it...if u use join ur perfomance will be reducd.
reward if useful
ravi
2007 Sep 06 1:22 PM
2007 Sep 06 1:33 PM
Better option i feel is join bseg and bkpf. Get data to internal table. For this records get data from SKAT & LFA1. This will have better performance than joining all 4 tables. Let me know if you need exact join fields and related psudocode.
Award points, if you find this solution helpful.
2007 Sep 06 1:40 PM
hi,
if u want to join more than 3 tables than go for views or use FOR ALL ENTRIES than joins as joins degrades performance of the program for more tables.
i think for ur purpose just create a database view and use in ur program.
if helpful reward some points.
with regards,
Suresh Aluri.
2007 Sep 06 1:45 PM
Hi Hemal,
You can use join statement to join at max four tables.
For your requirement you can do that.
Refer this pseudo code :
SELECT A~<Field Name>
A~<Field Name>
B~<Field Name>
B~<Field Name>
C~<Field Name>
C~<Field Name>
D~<Field Name>
D~<Field Name>
INTO CORRESPONDING FIELDS OF TABLE I_TAB
FROM BKPF AS A INNER JOIN
BSEG AS B ON A<Key Field> = B<Key Field>
SKAT AS C ON A<Key Field> = C<Key Field>
LFA1 AS D ON A<Key Field> = D<Key Field>
WHERE <Condition>.
Refer this two table joining code for joining four tables.
SELECT A~VBELN
A~FKDAT
A~KUNAG
A~KUNRG
B~NAME1
B~ORT01 INTO CORRESPONDING FIELDS OF TABLE I_INVOICE
FROM VBRK AS A INNER JOIN
KNA1 AS B ON
AKUNAG = BKUNNR
WHERE A~VBELN IN P_VBELN.
Reward points if helpful.
Regards,
Hemant.
2007 Sep 06 4:31 PM
Hi,
<b>First make not that you can not Join the table which is Cluster table.</b> BSEG is one of that kind of table and you can not join these
I would suggest Select from BKPF and then go to BSEG and use <b>For all entries </b>
and then go to SKAT ans use <b>For all Entries</b> and same way for LFA1
Thanks,
PK
2007 Sep 06 4:34 PM
JOin on 4 different tables is not recommended and BSEG is a cluster.
Try creating Views and use it or just go for select queries individually.
Shreekant
2007 Sep 07 6:56 AM
hi,
we can join those 4 tables , but in the performance level it is not recommended. But i am forwarding the sample code for that , go through it.
select a~bukrs
a~belnr
b~gjahr
b~buzei
c~lifnr
c~land1
d~saknr
d~mcod1
from bkpf as inner join bseg as b
on abukrs = bbukrs
inner join lfa1 as c
on blifnr = clifnr
inner join skat as d
on cmcod1 = dmcod1.
<b>please reward points if helpfull.</b>
with regards,
radhika kolluru.
2007 Sep 07 7:01 AM
Hi,
BESG is clustertable and JOINS doesnt work on Cluster tables.
Regards,
Naveen
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |