Inner joins using 3 tables
Try this :-
SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpo~stlnr = mast~stlnr
JOIN mara ON mara~matnr = mast~matnr
WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr
AND mast~werks = 1000.
Here s_matnr is a select-options on the selection-screen.
Or this.
Code:
Select single Vbrk~Bukrs Vbrk~Kunrg Vbrk~Vbeln
Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
Vbak~Vbeln Vbak~Bstdk
Likp~Vbeln Likp~lfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join Tvzbt on Tvzbt~Zterm = Vbrk~Zterm 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 Vbak~Vbeln = SalesLnk~Vbelv
Inner join Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on Likp~Vbeln = DeliveryLnk~Vbelv
where vbrk~vbeln = pu_Vbeln.
This code locates sales, delivery and payment terms info from a billing document number.
or
Here, this one also works fine :
select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura
zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1
zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint
into it_lista
from zfpcd inner join zcdvs
on zfpcd~ebeln = zcdvs~ebeln
and zfpcd~proforma = zcdvs~proforma
and zfpcd~lifnr = zcdvs~lifnr
inner join lfa1
on zfpcd~lifnr = lfa1~lifnr
where zcdvs~status = '04'.