Skip to Content
author's profile photo Former Member
Former Member

inner join

hi all,

can any one plz teel me how to write the inner join for this query..? im trying but its giving me errors..

select budat belnr into (itab-budat,itab-belnr) from bkpf
where bukrs in bukrs and budat between  budat-low and budat-high .


 select bukrs hkont gsber shkzg dmbtr into (itab-bukrs,itab-hkont,
 itab-gsber,itab-shkzg,itab-dmbtr) from bseg
 where bukrs in bukrs and hkont in hkont and gsber in gsber
 and belnr = itab-belnr.


 if sy-subrc = 0.

   append itab.
   clear itab.

 endif.

 endselect.
endselect.

thanx..

<LOCKED BY MODERATOR - USE APPROPRIATE TITLES>

Edited by: Alvaro Tejada Galindo on Dec 23, 2008 10:31 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 09:40 AM

    BSEG is a cluster table . You cannot have a join on it.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 09:44 AM

    hi,

    Sorry...

    Edited by: avinash kodarapu on Dec 23, 2008 3:15 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 09:51 AM

    so what is an alternative which and what kind of join on which table can be applied..

    thanx...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 09:51 AM

    Hi Nilesh,

    As mentioned by Ankesh, You can't use cluster or pool tables as your join tables.

    Please check the example JOINS. Use this on non cluster or pool tables.

    SELECT s~carrid s~carrname p~connid 
           INTO CORRESPONDING FIELDS OF TABLE itab 
           FROM scarr AS s 
           INNER JOIN spfli AS p ON s~carrid   =  p~carrid 
                                      AND p~cityfrom = p_cityfr. 
    
    

    If you cannot perfor JOINS then use FOR ALL ENTRIES. Please check the below code.

    SELECT BUDAT BELNR
      FROM BKPF
      INTO TABLE IT_BKPF
     WHERE bukrs in bukrs and budat between  budat-low and budat-high .
    
    IF SY-SUBRC EQ 0.
     
     select bukrs hkont gsber shkzg dmbtr 
     from bseg
     INTO TABLE IT_BSEG
     where bukrs in bukrs and hkont in hkont and gsber in gsber
     and belnr = itab-belnr.
    ENDIF.
    

    Thanks,

    Vinay

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 09:55 AM

    please ignore this;

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:04 AM
    select a~budat a~belnr 
    b~bukrs b~hkont b~gsber b~shkzg b~dmbtr into 
    (itab-budat,itab-belnr,itab-bukrs,itab-hkont,itab-gsber,itab-shkzg,
    tdmbtr) 
    from bkpf as a inner join  bseg as b on a~belnr = b~belnr
    where budat between  budat-low and budat-high and bukrs in bukrs and 
    bukrs in bukrs and hkont in hkont and gsber in gsber.

    im doing like this m i syntactically right..?

    thanx..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 10:11 AM

    Hi Nilesh,

    try it like this:

    select bkpf~bukrs
             bkpf~budat
             bkpf~belnr
        into table t_bkpf
        from bkpf 
       where bukrs in s_bukrs
         and budat in s_budat.
         
      select hkont
             gsber
             shkzg
             dmbtr
        into table t_bseg
         for all entries in t_bkpf
       where bukrs eq t_bkpf-bukrs
         and gsber in s_gsber
         and hkont in s_hkont.

    With luck,

    Pritam.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 23, 2008 at 11:20 AM

    HI,

    AS BSEG is the cluster table you can't use the innerjoin for that.

    you have to the use "For all entries" only

    Note: while using the cluster table you need to use the all primary keys in the where condition other wise you wont' get the proper data.

    for the BSEG you have to use the BUKRS,BELNR,GJAHR,BUZEI in the where condtion. with same sequance.

    Regards,

    Prasanth

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.