Application Development and Automation 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: 
Read only

Join

Former Member
0 Likes
1,053

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.

9 REPLIES 9
Read only

Former Member
0 Likes
967

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

Read only

rodrigo_paisante3
Active Contributor
0 Likes
967

Hi, try to see the link between the tables, see this link:

Regards

Reward points if useful!

Read only

Former Member
0 Likes
967

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.

Read only

Former Member
0 Likes
967

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.

Read only

Former Member
0 Likes
967

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.

Read only

Former Member
0 Likes
967

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

Read only

Former Member
0 Likes
967

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

Read only

Former Member
0 Likes
967

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.

Read only

Former Member
0 Likes
967

Hi,

BESG is clustertable and JOINS doesnt work on Cluster tables.

Regards,

Naveen