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

Table Join

Former Member
0 Likes
581

Hi,

I have to join 4 ztables . The joining is based on one common key.How can I do it?

regards..

1 ACCEPTED SOLUTION
Read only

dhruv_shah3
Active Contributor
0 Likes
557

HI,

use for all entries statement and every time compare that key with the internal table key field.

Eg.

select * from <tablename>

for all entries in <internal table>

where table field = internal table field.

HTH

Regards,

Dhruv Shah

4 REPLIES 4
Read only

Former Member
0 Likes
557

Hi ,

Check ths example qurey...

SELECT COUNT( * ) AS dcases

atrntyp aexdat

SUM( b~exbas ) AS exbas

SUM( b~exbed ) AS exbed

SUM( b~exaddtax1 ) AS exaddtax1

SUM( b~menge ) AS menge

SUM( b~ecs ) AS ecs

INTO CORRESPONDING FIELDS OF TABLE it_stock

FROM ( ( j_1iexchdr AS a

INNER JOIN j_1iexcdtl AS b

ON aexnum EQ bexnum

AND aexdat EQ bexdat

AND adocno EQ bdocno

AND adocyr EQ bdocyr )

INNER JOIN mara AS c

ON bmatnr EQ cmatnr )

WHERE a~exgrp EQ '11'

AND a~trntyp IN ('DLFC','CEIV','OTHR')

AND a~srgrp IN ('01','08')

AND a~expind NE 'D'

AND a~exdat IN s_budat

AND bmatnr EQ cmatnr

AND c~spart IN ('11','12')

GROUP BY atrntyp aexdat.

you can write your qurey similar to this...

<b>reward if useful</b>

Regards,

sunil kairam.

Read only

Former Member
0 Likes
557

Hi

look this example

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.

Regards

Aditya

Read only

dhruv_shah3
Active Contributor
0 Likes
558

HI,

use for all entries statement and every time compare that key with the internal table key field.

Eg.

select * from <tablename>

for all entries in <internal table>

where table field = internal table field.

HTH

Regards,

Dhruv Shah

Read only

Former Member
0 Likes
557

HI,

SELECT a~ebeln

*c~lifnr

a~bukrs
*c~name1
a~lifnr
*c~sortl
b~ebelp
*c~land1
b~matnr
b~werks
b~netpr
b~menge
INTO CORRESPONDING FIELDS OF TABLE t_data
FROM ekko as a
inner join ekpo as b on a~ebeln = b~ebeln
*inner join lfa1 as c on a~lifnr = c~lifnr
WHERE a~ebeln in s_ebeln
 AND a~lifnr in s_lifnr

Regards,

S.Nehru