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

how to use inner joins for 4 0r 5 tables

Hai Experts,

plz check my code, n plz help to inner join all the tables

TYPES : BEGIN OF ITAB,

EBELN TYPE EKKO-EBELN, "P.O.NUMBER

AEDAT TYPE EKKO-AEDAT, "DATE

BPRME TYPE EKPO-BPRME, "UNIT PRICE

MENGE TYPE EKPO-MENGE, "Purchase order quantity

WERKS TYPE EKPO-WERKS, "PLANT

BRTWR TYPE EKPO-BRTWR, "Gross order value in PO

STRAS TYPE LFA1-STRAS, "House number and street

LIFNR TYPE LFA1-LIFNR, "VENDOR NO

NAME1 TYPE LFA1-NAME1, "V NAME

ORT01 TYPE LFA1-ORT01, "CITY

LAND1 TYPE LFA1-LAND1, "LAND

PSTLZ TYPE LFA1-PSTLZ, "POSTAL CODE

MAKTX TYPE MAKT-MAKTX, "DESCRIPTION

END OF ITAB.

<b>and i got stucked here:</b>

<u></u>

SELECT EKKO~EBELN

EKKO~AEDAT

EKPO~BPRME

EKPO~MENGE

EKPO~WERKS

EKPO~BRTWR

LFA1~LIFNR

LFA1~STRAS

LFA1~NAME1

LFA1~ORT01

LFA1~LAND1

LFA1~PSTLZ

MAKT~MAKTX

INTO TABLE ITAB

FROM EKKO

INNER JOIN EKPO LFA1 T001W MAKT

ON EKKOEBELN = EKPOEBELN

EKKO~EBELN

WHERE EKKO~EBELN IN S_EBELN.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:46 AM

    Hi,

    Check the following link:

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

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:49 AM

    refer this...

    SELECT AMATNR AMTART BWERKS CLABST D~MAKTX FROM

    MARA AS A INNER JOIN MARC AS B ON

    AMATNR = BMATNR INNER JOIN MARD AS C ON

    BMATNR = CMATNR INNER JOIN MAKT AS D ON

    CMATNR = DMATNR INTO CORRESPONDING FIELDS OF TABLE ITAB

    WHERE A~MATNR IN SO_MATNR.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 09:51 AM

    hi Rajesh,

    you have to join the tables one by one:

    SELECT ekko~ebeln

    ekko~aedat

    ekpo~bprme

    ekpo~menge

    ekpo~werks

    ekpo~brtwr

    lfa1~lifnr

    lfa1~stras

    lfa1~name1

    lfa1~ort01

    lfa1~land1

    lfa1~pstlz

    makt~maktx

    INTO TABLE itab

    FROM ekko AS ekko

    INNER JOIN ekpo AS ekpo

    ON ekkoebeln EQ ekpoebeln

    INNER JOIN lfa1 AS lfa1

    ON ekkolifnr EQ lfa1lifnr

    INNER JOIN t001w AS t001w

    ON ekpowerks EQ t001wwerks

    INNER JOIN makt AS makt

    ON ekpomatnr EQ MAKTmatnr

    WHERE ekko~ebeln IN s_ebeln.

    This is the complete SELECT. BUT! The performance will be much better if you take out T001W and MAKT from the INNER JOIN. Do select on these tables in separate steps and merge the internal tables afterwards.

    hope this helps

    ec

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:52 AM

    Hi

    SELECT EKKO~EBELN

    EKKO~AEDAT

    EKPO~BPRME

    EKPO~MENGE

    EKPO~WERKS

    EKPO~BRTWR

    LFA1~LIFNR

    LFA1~STRAS

    LFA1~NAME1

    LFA1~ORT01

    LFA1~LAND1

    LFA1~PSTLZ

    MAKT~MAKTX

    INTO TABLE ITAB

    FROM EKKO

    INNER JOIN EKPO

    ON EKKOEBELN = EKPOEBELN join LFA1 on EKKOlifnr = lfa1lifnr join

    T001W on ekpowerks = t001Wwerks join MAKT

    EKpOmatnr = maktmatnr

    WHERE EKKO~EBELN IN S_EBELN.

    regards

    anji

    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.