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: 

Inner join

Former Member
0 Kudos

hi experts,

i have to write inner join for theree tables mara,marc,makt comman field MATNR(primary key)

how to write Could u please help me

Thanks

siri

8 REPLIES 8

dani_mn
Active Contributor
0 Kudos

HI,

Inner join is simple join so you can use both key words 'JOIN' or 'INNER JOIN'. both are same.

if you want to write outer join then you have to mention 'LEFT OUTER JOIN'.

   select bs~belnr bs~bukrs bs~gsber
             bs~kostl bs~budat bs~hkont
             bs~dmbtr bs~shkzg bs~buzei
             bs~gjahr fm~fonds
      into table fw_expense_temp
      from bsis as bs
<b>      inner join fmifiit as fm</b>
      on ( bs~hkont = fm~hkont and
           bs~bukrs = fm~bukrs and
           bs~kostl = fm~fistl and
           bs~belnr = fm~knbelnr )
<b>      inner join zrange as zr</b>
      on ( bs~gsber = zr~gsber and
           bs~bukrs = zr~bukrs )
      where
        bs~hkont in hkt and
        bs~budat >= prev_yr_st_date and
        bs~budat <= curr_yr_end_date and
        bs~bukrs in bukrs and
        prctr in
        ( select prctr
          from zprofit_valid
          where uname = sy-uname ).

Regards,

HRA

Message was edited by: HRA

Former Member
0 Kudos

Hi,

Consider you have to fetch material, desc., and plant details :

Parameters : p_matnr like mara-matnr.

select mmatnr mdmaktx wwerks into corresponding fields of table it_mara from mara as m inner join marc as w on mmatnr = wmatnr inner join makt as md on mmatnr = mdmatnr where mmatnr = P_MATNR and md~spras = 'EN'.

check sy-sybrc = 0.

Reward if convinced with the answer.

regards

former_member181962
Active Contributor
0 Kudos

select mara~matnr

mara~<some field in mara>

marc~<some field in marc>

makt~<some field in makt>

from mara inner join marc

on maramatnr = marcmatnr

inner join makt

on maramatnr = maktmatnr

into corresponding fields of table it_data

where matnr in s_matnr...

Former Member
0 Kudos

Hi,

select * into wa

from ( mara as m inner join marc as mc

on mmatnr = mcmatnr )

inner join makt as mk

on mmatnr = mkmatnr

Regards,

Sowjanya

0 Kudos

Hi,

Check this..

http://www.sap-img.com/abap/inner-joins.htm

Cheers

VJ

former_member188685
Active Contributor
0 Kudos

Hi,

   parameters: p_matnr type mara-matnr.
data: begin of itab occurs 0,
      matnr like mara-matnr,
      werks like marc-werks,
      maktx like makt-maktx,
       end of itab.
select mara~matnr
       marc~werks
       makt~maktx
       from mara inner join marc
       on mara~matnr = marc~matnr
       inner join makt
       on mara~matnr = makt~matnr
       into table itab
       where mara~matnr = p_matnr
         and makt~spras = 'EN'.
      

Regards

vijay

Former Member
0 Kudos

....

Former Member
0 Kudos

http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm

Message was edited by: Khimavath Vikranth

Message was edited by: Khimavath Vikranth