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

tables

Former Member
2 REPLIES 2
Read only

Former Member
0 Likes
358

Hi,

<b>Inner joins using 3 tables </b>

<b>Try this :-</b>

SELECT stpostlnr stpoidnrk mastmatnr maramtart stpo~menge

INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast

JOIN stpo ON stpostlnr = maststlnr

JOIN mara ON maramatnr = mastmatnr

WHERE stpostlty = 'M' "AND stpoidnrk IN s_matnr

AND mast~werks = 1000.

Here s_matnr is a select-options on the selection-screen.

<b>Or this. </b>

Code:

Select single VbrkBukrs VbrkKunrg Vbrk~Vbeln

VbrkFkdat VbrkBstnk_Vf Vbrk~Zterm

Tvzbt~Vtext

VbakVbeln VbakBstdk

LikpVbeln Likplfdat Likp~Lfuhr

into w_vbrk

from vbrk

inner join Tvzbt on TvzbtZterm = VbrkZterm and

Tvzbt~Spras = sy-langu

Inner join Vbfa as SalesLnk

on SalesLnk~vbeln = pu_vbeln and

SalesLnk~vbtyp_v = c_order

inner join Vbak on VbakVbeln = SalesLnkVbelv

Inner join Vbfa as DeliveryLnk

on DeliveryLnk~vbeln = pu_vbeln and

DeliveryLnk~vbtyp_v = c_Delivery

inner join Likp on LikpVbeln = DeliveryLnkVbelv

where vbrk~vbeln = pu_Vbeln.

This code locates sales, delivery and payment terms info from a billing document number.

<b>or

Here, this one also works fine :</b>

select zfpcdcadivi zfpcdproforma zfpcdfactura zfpcdaniofactura

zfpcdmontousd zfpcdmontoap zfpcdebeln zfpcdinco1

zfpcdlifnr lfa1name1 zcdvsstatus zfpcdconint

into it_lista

from zfpcd inner join zcdvs

on zfpcdebeln = zcdvsebeln

and zfpcdproforma = zcdvsproforma

and zfpcdlifnr = zcdvslifnr

inner join lfa1

on zfpcdlifnr = lfa1lifnr

where zcdvs~status = '04'.

Regards

Sudheer

Read only

Former Member
0 Likes
358

You can use INNER JOIN or OUTER JOIN to join any number of tables.

Eg:

SELECT t685kschl t682zkozgf t682ikotabnr t682zkvewe

t682zkappl t682zkolnr zaehk zifna

FROM t685

INNER JOIN t682i

ON t685kvewe eq t682ikvewe and

t685kappl eq t682ikappl and

t685kozgf eq t682ikozgf

INNER JOIN t682z

ON t682ikvewe eq t682zkvewe and

t682ikappl eq t682zkappl and

t682ikozgf eq t682zkozgf and

t682ikolnr eq t682zkolnr

INTO TABLE gt_t682

WHERE t685~kvewe = 'A' AND " 'A' - Pricing

t685~kappl = 'V' AND " 'V' - Sales/Distribution

t685~kschl IN gr_kschl AND

t682z~qustr NE ''.

Regards

Sri