Application Development 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: 

how to use outer join on 3 tables

Former Member
0 Kudos

how to use outer join on 3 tables

say tables are mkpf,lips and vbrp

mkpf-xblnr = lips-vbeln

lips-vbeln = vbrp-vgbel

7 REPLIES 7

Former Member
0 Kudos

refer following querry

select a~bukrs

a~anln1

a~ord42

a~ord43

b~afabe

b~ndabj

b~kaafa

b~aafag

c~kostl

d~afasl

d~ndjar

d~ndper

into corresponding fields of table gt_master

from ( ( anla as a inner join anlc as b

on abukrs = bbukrs

and aanln1 = banln1

and aanln2 = banln2 )

inner join anlz as c

on abukrs = cbukrs

and aanln1 = canln1

and aanln2 = canln2 )

inner join anlb as d

on abukrs = dbukrs

and aanln1 = danln1

and aanln2 = danln2

where a~bukrs in s_comp.

Former Member
0 Kudos

Hi Amit,

See this example code.

DATA: BEGIN OF wa,

carrid TYPE scarr-carrid,

carrname TYPE scarr-carrname,

connid TYPE spfli-connid,

END OF wa,

itab LIKE SORTED TABLE OF wa

WITH NON-UNIQUE KEY carrid.

SELECT scarrid scarrname p~connid

INTO CORRESPONDING FIELDS OF TABLE itab

FROM scarr AS s

LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid AND

p~cityfrom = 'FRANKFURT'.

LOOP AT itab INTO wa.

WRITE: / wa-carrid, wa-carrname, wa-connid.

ENDLOOP.

Plzz Reward if useful,

Mahi.

0 Kudos

please explain me how to do it for 3 tables.

i am able to do it for 2 table but i want it for 3 tables, mkpf,lips and vbrp

can any1 help me out

Former Member
0 Kudos

Hi Amit,

This is kiran kumar.G.I have to send sample SELECT statement for outer join plz check it once.

If u r satify with my answer give me REWARD POINTS.

i have to take some fields from the 3 tables u have to change

the fields according to ur requirement..okk..

select a~vbeln

a~vrkme

a~ntgew

b~erdat

b~posnr

c~xblnr

c~blart

from vbrp as a

outer join lips as b on avbeln = bvbeln

outer join mkpf as c on avbeln = cxblnr

into table itab

where vbeln in s_vbeln.

I will check the above code that is executing successfully

check it once

Regards,

Kiran Kumar.G

Former Member
0 Kudos

use this Query as reffrence

SELECT

b~matnr

b~charg

c~kunnr

d~ort01 AS city

b~erdat

c~zzins_face

INTO CORRESPONDING FIELDS OF TABLE ist_pending_delivery

FROM vbfa AS a INNER JOIN lips AS b

ON avbeln = bvbeln

AND aposnn = bposnr

LEFT JOIN likp AS c

ON cvbeln = bvbeln

INNER JOIN kna1 AS d

ON dkunnr = ckunnr

WHERE a~vbelv = wa_ist_sodtl-vbeln

AND a~posnv = wa_ist_sodtl-posnr

AND a~vbtyp_n = 'J'.

Former Member
0 Kudos

If u want, u mention ur conditions(lips-vbeln = vbrp-vgbel) in the above outer join ok..

Regards,

Kiran Kumar.g

0 Kudos

select amblnr abudat bvbeln bposnr

into corresponding fields of table itab

from mkpf as a outer join lipsas c on axblnr = cvbeln

outer join vbrp as b

on bvgbel = cvbeln

and bvgpos = cposnr.

where am i goin wrong in the above select statement

i am gettin an error for it