Skip to Content

how to use innerjoin and select for all entries together

pls let me know

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Sep 08, 2007 at 11:13 AM

    Hi Aarif,

    Firstly to say the difference b/w for all and inner join would be..

    1. INNER JOIN

    DBTAB1 <----


    > DBTAB2

    It is used to JOIN two tables

    having some COMMON fields.

    2. Whereas

    For All Entries,

    DBTAB1 <----


    > ITAB1

    is not at all related to two tables.

    It is related to internal table.

    3. If we want to fetch data

    from some DBTABLE1

    but we want to fetch

    for only some records

    which are contained in some internal table,

    then we use for alll entries.

    Remember performance wil be very bad when you use both inner join and for all entries as for all entries is also another type of join.

    A code that shows usage of both using MARA and MAKT tabs.

    select mara~matnr makt

    into corresponding fields table of itab

    from mara

    join makt on maramatnr = maktmatnr

    and makt~spras = sy-langu

    for all entries in itab

    where matnr = itab-matnr.

    <b>

    Reward if found useful.</b>

    Regards,

    harish

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 06:04 AM

    Joins: joins will work on 2 DB tables.

    SELECT A~KTOPL

    A~ERSDA

    A~KSTSN

    B~KOKRS

    B~KSTAR

    B~DATBI

    B~KATYP

    C~SPRAS

    C~KTEXT

    C~LTEXT INTO CORRESPONDING FIELDS OF TABLE ITAB

    FROM CSKA AS A

    INNER JOIN CSKB AS B ON AKSTAR = BKSTAR

    INNER JOIN CSKU AS C ON BKSTAR = CKSTAR

    WHERE A~KSTAR IN S_KTO.

    For all entries: in this first get data from one table and use that one in second query.

    SELECT * FROM CSKA INTO TABLE IT_CSKA WHERE KSTAR IN S_KSTAR.

    IF SY-SUBRC = 0.

    SORT IT_CSKA BY KSTAR.

    ENDIF.

    SELECT * FROM CSKB INTO TABLE IT_CSKB

    FOR ALL ENTRIES IN IT_CSKA

    WHERE KSTAR = IT_CSKA-KSTAR.

    I hope u can understand.

    Award points helpful.

    brahmaji.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:42 AM

    Hi Aasif,

    Use the Synatx as accordingly.

    **********************************************************************************************

    sort it_data by matnr werks.

    select bmatnr bwerks abedvp from t461s as a inner join marc as b on astra1 = b~strgr into table it_strgt For all entries in it_data where matnr = it_data-matnr and werks = it_data-werks.

    **********************************************************************************************

    Hope this resolves your query.

    Reward All the helpful answers.

    Regards

    Nagaraj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 08:57 AM

    See the below example.

    SELECT ekko~bukrs

    ekko~lifnr

    ekko~ebeln

    ekko~waers

    ekko~bsart

    ekko~ekorg

    ekko~ekgrp

    ekpo~ebelp

    ekpo~txz01

    ekpo~matnr

    ekpo~werks

    ekpo~menge

    ekpo~meins

    ekpo~netpr

    ekpo~netwr

    INTO TABLE t_itab1 FROM

    ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln

    WHERE ekko~ebeln IN s_ebeln AND

    ekko~bukrs IN s_bukrs AND

    ekko~lifnr IN s_lifnr AND

    ekko~ekorg IN s_ekorg AND

    ekko~ekgrp IN s_ekgrp AND

    ekpo~matnr IN s_matnr AND

    ekko~bsart = p_bsart.

    ENDIF.

    IF NOT t_itab1[] IS INITIAL.

    • FETCHING NAME1

    SELECT werks

    name1

    FROM t001w

    INTO TABLE t_name1

    FOR ALL ENTRIES IN t_itab1

    WHERE werks = t_itab1-werks.

    SORT t_itab1 BY werks.

    SORT t_name1 BY werks.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 19, 2007 at 01:58 PM

    use innerjoin technique and sort the itab so that all the duplicate rows will be gone

    select * from mara as ma innerjoin marc as mr on mamatnr = mrmatnr innerjoin into table itab.

    after that declare this so that duplicate rows wii be gone

    sort itab.

    regards

    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.