Join on 3 tables using inner join.

Hi friends can one one correct the below code and send me back.
its showing some error.
SELECT a~matnr
           a~werks
           b~maktx
           c~prctr
           c~bklas
           C~stprs
           c~peinh
          INTO TABLE it_detail
          FOR ALL ENTRIES IN itab
          FROM marc AS a INNER JOIN makt AS b
          ON amatnr = bmatnr
          inner join mbew AS c
          WHERE a~matnr = itab-matnr
          and     werks = itab-werks.

Hi,
Pls find the below piece of code.
     begin of it_detail occurs 0,
           matnr like mara-matnr,
           werks like marc-werks,
           prctr like marc-prctr,          
           maktx like makt-maktx,
           bklas like mbew-bklas,
           stprs like mbew-stprs,
           peinh like mbew-peinh,
     end   of it_detail.
SELECT a~matnr
a~werks
a~prctr
b~maktx
c~bklas
C~stprs
c~peinh
INTO TABLE it_detail
FROM marc AS a INNER JOIN makt AS b
ON amatnr = bmatnr
inner join mbew AS c
on amatnr = cmatnr
FOR ALL ENTRIES IN itab
WHERE a~matnr = itab-matnr
and   a~werks = itab-werks.
if it is not working, pls send me the error message that you are getting.
Thanks,
Sreeram.
Edited by: Sreeram Prasad on Aug 19, 2008 5:07 PM
Edited by: Sreeram Prasad on Aug 19, 2008 5:12 PM

Similar Messages

  • Delete query using inner join

    I need to delete records from a table using inner join from other tables. See below for the table structure and records.
    CREATE TABLE STUDENT (ROLL_NO NUMBER(10),NAME VARCHAR2(100),DEPT_NO NUMBER(10),JOIN_DATE DATE);
    CREATE TABLE DEPART (DEPT_NO NUMBER(10), DEPT_NAME VARCHAR2(100));
    CREATE TABLE ACTIVE_DEPT (DEPT_NO NUMBER(10), IS_ACTIVE VARCHAR2(1));
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(1,'SAM',10,SYSDATE-10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(2,'ALEX',10,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(3,'FRANK',20,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(4,'WAYNE',20,SYSDATE+1);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(5,'KRUL',30,SYSDATE -10);
    INSERT INTO STUDENT (ROLL_NO,NAME,DEPT_NO,JOIN_DATE) VALUES(6,'ALICE',40,SYSDATE -10);
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (10,'DEPT1');
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (20,'DEPT2');
    INSERT INTO DEPART (DEPT_NO,DEPT_NAME) VALUES (30,'DEPT3');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (10,'Y');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (20,'N');
    INSERT INTO ACTIVE_DEPT (DEPT_NO,IS_ACTIVE) VALUES (30,'Y');
    DELETE FROM STUDENT WHERE (STUDENT.DEPT_NO) IN (SELECT D.dept_no FROM DEPART D,ACTIVE_DEPT AD WHERE D.DEPT_NO = AD.DEPT_NO AND AD.IS_ACTIVE = 'N');The above delete query will delete two records from the STUDENT table. Now i want to include another condition say, join_date should be a past date (join_date < trunc(sysdate)).
    How to include this condition in the above delete statement. I know i can do this using a subquery but i wont prefer that option. Basically i don't have much idea about join in delete statements.
    Please help.

    Is this you need ?
    DELETE FROM student WHERE join_date < TRUNC(SYSDATE)
                                            AND student.dept_no IN (SELECT D.dept_no
                                                                      FROM depart d,active_dept ad
                                                                     WHERE d.dept_no = ad.dept_no AND ad.is_active = 'N');Only one record is deleted. -> 3,'FRANK',20,SYSDATE -10
    >
    Balaji      wrote:
    Yes. But here we are getting the dept_no from the sub query, is there a better way to achieve this without sub query?
    >
    As far I know you need to have sub query in this case.
    You can close this thread if answered. If you have any further queries please post it so that someone can help you.
    Edited by: Lokanath Giri on २० मार्च, २०१२ ५:०५ अपराह्न

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • How to use INNER JOIN in such case

    when i program as below[CASE1]. the code is able to active.
    CASE1:
    ==========================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                  CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE)
                WHERE BUKRS = I_BUKRS.
      ENDFORM.                   
    ===========================
    but when I need to INNER JOIN another table [CASE2]
    CASE2:
    =======================
    DATA: WK_BUKRS LIKE T001-BUKRS,
          WK_BUTXT LIKE T001-BUTXT,
          WK_TABLE(4) TYPE C VALUE 'T001'.
    START-OF-SELECTION.
      WK_BUKRS = 'DECN'.
      PERFORM GET_BUTXT USING WK_BUKRS WK_TABLE
                     CHANGING WK_BUTXT.
      WRITE: WK_BUTXT.
      FORM GET_BUTXT USING I_BUKRS LIKE T001-BUKRS
                           I_TABLE
                    CHANGING O_BUTXT LIKE T001-BUTXT.
        SELECT SINGLE BUTXT
                 INTO O_BUTXT
                 FROM (I_TABLE) AS G INNER JOIN BKPF AS H
                   ON GBUKRS = HBUKRS
                WHERE G~BUKRS = I_BUKRS.
      ENDFORM.          
    =================================
    Syntax error:
    Wrong expression "INNER" in FROM clause. WHERE condition.
    Can anybody help me to solve the problem.
    My requirement is to use INNER JOIN with variable table

    hi slam,
    chk this sample code.
    hi,
    table emp
    empno name
    a sasi
    b xxx
    c yyy
    table sal
    empno salary
    a 1000
    b 2000
    Inner join
    select eempno ename
    s~sal
    into table int_table
    from emp as e
    inner join sal as s
    on
    eempno = sempno.
    if you made inner join between table a and b by emp no
    the selection retrives only if the condition satisfy the output will be
    a sasi 1000
    b xxx 2000
    rgds
    anver
    if hlped mark points
    Message was edited by: Anversha s

  • Select querry using inner join

    Hi Friends,
    I need to fetch data from two tables, I used inner join but I am not able to fetch the data in some fields can any one tell me what is wrong in this select querry.
    SELECT but000~partner
             but000~name_org1
             but000~name_first
             but000~name_last
             but000~bpext
          FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart
        INTO table lt_but000
        WHERE but000~partner IN so_part
        AND dfkkop~faedn IN so_faedn.
    Thanx in advance,
    Parvez

    hi Lutin,
    SELECT but000~partner
    but000~name_org1
    but000~name_first
    but000~name_last
    but000~bpext
    FROM but000 INNER JOIN dfkkop ON but000partner = dfkkopgpart  <------check this condition,it has to *satisfy  both table                                                                        
    INTO table lt_but000
    WHERE but000~partner IN so_part
    AND dfkkop~faedn IN so_faedn.
    Regards,
    siva
    Message was edited by:
            SivaKumar

  • Want to add one more table in Inner join

    Hi all,
    my code is show below.
    SELECT a~budat a~mblnr b~matnr b~menge b~bwart
             INTO CORRESPONDING FIELDS OF TABLE it_rawmat
             FROM mkpf as a inner join mseg as b on a~mblnr = b~mblnr
             where b~bwart = '261' and b~werks in werks and b~matnr in matnr and a~budat in budat.
    this code is get two table with inner join.
    But now i want to get BOM quantity from Mast and stpo so can u please help me how can i add this both table in this
    select statement.
    i describe stlnr,menge,idnrk,matnr this four field in it_rawmat table.
    now how can i fetch value MENGE from stpo throw mast .
    Thanks in Advance
    keyur

    Here is sample example where more then two tables are join.
    SELECT  p~carrid p~connid f~fldate b~bookid
      INTO  CORRESPONDING FIELDS OF TABLE itab
      FROM  ( ( spfli AS p
                INNER JOIN sflight AS f ON p~carrid = f~carrid AND
                                           p~connid = f~connid    )
                INNER JOIN sbook   AS b ON b~carrid = f~carrid AND
                                           b~connid = f~connid AND
                                           b~fldate = f~fldate     )
      WHERE p~cityfrom = 'FRANKFURT' AND
            p~cityto   = 'NEW YORK'  AND
            f~seatsmax > f~seatsocc. 

  • Joining multiple tables using ANSI join

    Hi,
    I need to join 4 tables using ANSI join. Lets say they are A,B,C adn D. A and B has a common column called x. C and D had a common column called y. I wrote a query like this
    select * from A left outer join B on (A.x=B.x),
    C left outer join D on (C.y =D.y)
    its not working!!!
    I need to use ANSI join.
    can any body help me please???

    Hi,
    But is there is any common column between A,C or B,C or D,A?
    Let me know.

  • Relationship between tables while using inner joins.

    Hi,
    I had a few clarifications on "inner joins", and as i was going through the forum, i came across two points,
    1. In one of the threads it said " inner joins is applicable for tables that have a parent child relationship.
    2. In another thread it said " inner join is established from master table (the table on the left) to the transcation table (the table on the right)".
    I have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2.  Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>.
    Edited by: Narayananchandran on Dec 27, 2010 12:31 PM

    have two clarifications based on the above points.
    1. Is it necessary that the tables on which im performing an inner join should have a parent-child/children relationship or is it enough that the tables just have a common field.
    2. Also is it necessary that the master table should come first, (or can i use any child table from where i can fetch the records when there is a mater table in my report) as shown below.
    Eg: select * <fields> from <master table> inner join <table> on <field> into <itab>
    1) NO
                      2) NO

  • How to use Inner join of table as Source in Merge statement in SQL

    Hi All,
        I am trying to make source as multiple tables output using Join while coding there is no any syntax error but when i am executing this statement is giving following error
    Following is the query 
    Merge Into EmpDept Target
    Using (select E.Address,e.Design,e.EmailId,e.EmpId,e.Ename,e.ManagerId, e.Salary,D.DeptId,D.DeptName,D.Location from Employee E Inner join Dept D on E.DeptId=D.DeptId )As Source (Address,Design,EmailId,EmpId,EName,ManagerId,Salary,DeptId,DeptName,Location)
    On Source.EmpId=Target.EmpId
    when not matched then
    Insert (Target.Address,Target.Design,Target.EmailId,Target.EmpId,Target.Ename,Target.ManagerId, Target.Salary,Target.DeptId,Target.DeptName,Target.Location)
    values
    (Address,Design,EmailId,EmpId,EName,ManagerId, Salary,DeptId,DeptName,Location)
    When matched then 
    Update set Target.Address = Source.Address ,Target.Design = Source.Design,Target.EmailId      = Source.EmailId     ,Target.Ename       = Source.Ename      ,Target.ManagerId = Source.ManagerId , Target.Salary        = Source.Salary       ,Target.DeptId      = Source.DeptId      ,Target.DeptName = Source.DeptName ,Target.Location    = Source.Location;
    This is error while executing the above merge statement 
    The insert column list used in the MERGE statement cannot contain multi-part identifiers. Use single part identifiers instead.
    Please suggest me where i am wrong.. 
    Niraj Sevalkar

    MERGE INTO EmpDept Target
    Using (SELECT E.Address,
    e.Design,
    e.EmailId,
    e.EmpId,
    e.Ename,
    e.ManagerId,
    e.Salary,
    D.DeptId,
    D.DeptName,
    D.Location
    FROM Employee E
    INNER JOIN Dept D
    ON E.DeptId = D.DeptId) AS Source (Address, Design, EmailId, EmpId, EName, ManagerId, Salary, DeptId, DeptName, Location)
    ON Source.EmpId = Target.EmpId
    WHEN NOT matched THEN
    INSERT (Address,
    Design,
    EmailId,
    EmpId,
    Ename,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    VALUES (Address,
    Design,
    EmailId,
    EmpId,
    EName,
    ManagerId,
    Salary,
    DeptId,
    DeptName,
    Location)
    WHEN matched THEN
    UPDATE SET Address = Source.Address,
    Design = Source.Design,
    EmailId = Source.EmailId,
    Ename = Source.Ename,
    ManagerId = Source.ManagerId,
    Salary = Source.Salary,
    DeptId = Source.DeptId,
    DeptName = Source.DeptName,
    Location = Source.Location;

  • How to use Inner Join for these 4 table's

    Hi Guys,
                  My Requirement is i have to get the data into the final Internal table whose structure is like this (BWKEY   type  MBEW-BWKEY,
            MATNR   type  MBEW-MATNR,
            MAKTX   type  MAKT-MAKTX,
            BWTTY   type  MBEW-BWTTY,
            BWTAR   type  MBEW-BWTAR,
            MEINS   type  MARA-MEINS,
            BKLAS   type  MBEW-BKLAS,
            VPRSV   type  MBEW-VPRSV,
            STPRS   type  MBEW-STPRS,
            PEINH   type  MBEW-PEINH,
            CRCY(3)    type  c,
            LBKUM   type  MBEW-LBKUM,
            SALK3   type  MBEW-SALK3,
            LAEPR   type  MBEW-LAEPR,
            J_3ADEFSI   type  MARC-J_3ADEFSI,
            J_4kDEFSC   type  MARC-J_4kDEFSC,
            SCLAS   type  MARA-/AFS/SCLAS,
            EKALR   type  MBEW-EKALR,
            HKMAT   type  MBEW-HKMAT,
            HRKFT   type  MBEW-HRKFT,
            KOSGR   type  MBEW-KOSGR,
            PRCTR   type  MARC-PRCTR,
            MMSTA   type  MARC-MMSTA,
            SOBSK   type  MARC-SOBSK,
            PPRDL   type  MBEW-PPRDL,
            LPLPR   type  MBEW-LPLPR,
            PPRDZ   type  MBEW-PPRDZ,
            ZPLPR   type  MBEW-ZPLPR)
                  from 4 table's MBEW , MARA MAKT and MARC.
         Can anybody provide the logci for this based on the below requirement
    "Go to table MBEW with material number, plant and valuation type; fetch the information laid out in output format. There are some fields which need to come from tables MARC, MARA and MAKT. The common criterion is material number across these tables.
    MBEW-MATNR = MARC-MATNR
    MBEW-MATNR = MARA-MATNR
    MBEW-MATNR = MAKT-MATNR
    Thanks,
    Gopi.

    Hello Gopi,
    I did not have system now and just written in notepad..
    types : begin of ty_mbew ,
    MATNR type MBEW-MATNR,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c, " What is this field ,i did not include in join
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_mbew.
    types : begin of ty_makt ,
    matnr type makt-maktx,
    MAKTX type MAKT-MAKTX,
    end of ty_makt.
    types : begin of ty_final ,
    MATNR type MBEW-MATNR,
    MAKTX type MAKT-MAKTX,
    BWTTY type MBEW-BWTTY,
    BWTAR type MBEW-BWTAR,
    MEINS type MARA-MEINS,
    BKLAS type MBEW-BKLAS,
    VPRSV type MBEW-VPRSV,
    STPRS type MBEW-STPRS,
    PEINH type MBEW-PEINH,
    CRCY(3) type c,
    LBKUM type MBEW-LBKUM,
    SALK3 type MBEW-SALK3,
    LAEPR type MBEW-LAEPR,
    J_3ADEFSI type MARC-J_3ADEFSI,
    J_4kDEFSC type MARC-J_4kDEFSC,
    SCLAS type MARA-/AFS/SCLAS,
    EKALR type MBEW-EKALR,
    HKMAT type MBEW-HKMAT,
    HRKFT type MBEW-HRKFT,
    KOSGR type MBEW-KOSGR,
    PRCTR type MARC-PRCTR,
    MMSTA type MARC-MMSTA,
    SOBSK type MARC-SOBSK,
    PPRDL type MBEW-PPRDL,
    LPLPR type MBEW-LPLPR,
    PPRDZ type MBEW-PPRDZ,
    ZPLPR type MBEW-ZPLPR,
    end of ty_final.
    Internal tables
    data :i_mbew type standard table of ty_mbew,
    i_makt type standard table of ty_makt,
    i_final type standard table of ty_final.
    Work Areas
    data : wa_mbew like line of i_mbew,
    wa_makt like line of i_makt,
    wa_final like line of i_final.
    start-of-selection.
    get the data from MBEW,MARA,MARC Table
    select aMATNR aBWTTY
           aBWTAR bMEINS
           aBKLAS aVPRSV
           aSTPRS aPEINH
    *CRCY(3) type c,
    aLBKUM aSALK3 a~LAEPR
    c~J_3ADEFSI type MARC-J_3ADEFSI,
    c~J_4kDEFSC type MARC-J_4kDEFSC,
    b~SCLAS type MARA-/AFS/SCLAS,
    aEKALR aHKMAT
    aHRKFT aKOSGR
    cPRCTR cMMSTA
    cSOBSK aPPRDL
    aLPLPR aPPRDZ
    a~ZPLPR into corresponding fields of table i_mbew
            from mbew as a inner join mara as b on bmatnr = amatnr
            inner join marc as c on cmatnr = amatnr.
    if sy-subrc eq 0.
    select matnr maktx from makt into table i_makt
                 for all entries in i_mbew
                 where matnr = i_mbew-matnr
                 and   spras = sy-langu.
    endif.
    loop at i_mbew into wa_mbew.
    read the data from MAKT Table
    read table i_makt into wa_makt with key matnr = wa_mbew-matnr.
    if sy-subrc eq 0.
    move-corresponding wa_mbew to wa_final.
    move wa_makt-maktx to wa_final-maktx.
    append wa_final to i_final.
    endif.
    endloop.
    Thanks
    Seshu

  • 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.

    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

  • Why can't i use "INNER JOIN" in a query for SQL Server with JDBC??????

    Hi,
    I'm trying to execute some SQL queries and I just don't understand what's wrong.
    I�m using Tomcat and SQL Server in order to do this, but when I�m try to execute a query with a INNER JOIN statements Tomcat raise a SQL exception... at the very first time I thought there was a problem with database connection but I realize that a simple query to a table works pretty well. then I found out some problems with JDBC:ODBC.... so I install JDBC for SQL Server 2000 and test with the same simple query and works..... so, I come to a conclusion.... INNER JOIN or JOIN statements can't be used in JDBC..... please... somebody tell I�m wrong and give me a hand...
    I'm using TOMCAT 4 and JDK 1.4 SQL Server 2000
    Error occurs when executeQuery() is called.... not prepareStatement().... ??????
    Driver DriverRecResult = (Driver)Class.forName(driver).newInstance();
    Connection ConnRecResult = DriverManager.getConnection(DSN,user,password);
    PreparedStatement StatementRecResult = ConnRecResult.prepareStatement(query);
    ResultSet RecResult = StatementRecResult.executeQuery(); <---- Exception raise here
    So much tahnks in advance,

    That's exactly what I think, driver it's raising the exception, but I don't know why.... i test the same query with INNER JOIN directly from SQL Query Analyser and it's works perfectly, my problem ain't SQL, but JSP and JDBC 'cause i'm a newbie about these issues.
    Common sense tell me possible problems lie in SQLServer drivers 'cause i run the same pages on JRUN through jdbc:odbc and do works well, but by now i just depend on Tomcat.....
    I've installed SQL Server drivers for JDBC but i just find it doesn't work fully... could be the version of JDK i've installed? what version do i need?
    ( I'm running Tomcat 4 with JDK 1.4 & SQL Server 2000 W2K )
    thanks for reply.

  • How to use BKPF and BSEG without using  inner join

    Hi,
    can anybody plz tell me the logic about how to complete the report without inner joining bkpf and bseg.Is this report can be really be made by using only bseg,bkpf ?
    *selection-criteria .
    BKPF-USNAM
    BKPF-CPUDT
    BKPF-BUDAT
    BKPF-GJAHR
    BKPF-BUKRS
    BKPF-BELNR
    BSEG-SAKNR
    BSEG-LIFNR
    BSEG-KUNNR
    BSEG-ZUONR
    BSEG-SGTXT
    Output fields required.
    BKPF-BUKRS
    BKPF-BELNR
    BKPF-GJAHR
    BKPF-MONAT
    BKPF-BLART
    BKPF-CPUDT
    BKPF-BLDAT
    BKPF-BUDAT
    BKPF-USNAM
    BKPF-XBLNR
    BKPF-STBLG
    BKPF-BKTXT
    BKPF-WAERS
    BKPF-KURSF
    BSEG-BUZEI
    BSEG-BSCHL
    BSEG-KOART
    BSEG-UMSKZ
    BSEG-SHKZG
    BSEG-MWSKZ
    BSEG-PSWBT
    BSEG-PSWSL
    BSEG-DMBTR
    BSEG-SAKNR
    BSEG-HKONT
    BSEG-KOSTL
    BSEG-KUNNR
    BSEG-VBELN
    BSEG-LIFNR
    BSEG-ANLN1
    BSEG-ANLN2
    BSEG-AUFNR
    BSEG-MATNR
    BSEG-MENGE
    BSEG-MEINS
    BSEG-ZUONR
    BSEG-SGTXT
    Thanks,
    Rahman
    Moderator Message: Please search before posting your question. Thread locked.
    Edited by: Suhas Saha on Jan 31, 2012 3:07 PM

    Quick question - what's preventing your from using built-in functions?
    I suggest mapping your Time Dim to a standard Time Dim and work with it - you'll save a lot more time. You'd even need this table if you wanted to work around Todate/AGO.
    It is possible to model this functionality w/o functions, but it'll be time consuming task, similar to using Time Series Wizard in Siebel Analytics. You'll need to build aliases and views along with some complex joins (such as TIME.KEY=TIME.KEY-365), introduce a bunch of variables to control. Also, you might not get much flexibility in terms of years. For each year, you'd need an alias table. (TIME_DIM_PY).

  • Can we use inner joins with for all entries?

    Hi,
        Can we use innerjoin on two tables MARA and MAKT against the materials in
        the  internal table.
        If so ,please let me know whether there is performance issue.Because if there is
        bad performance issue or something else like thise means,my project manager
        wont allow to include.
        So can one let me know about this.
    Thanks,
    Balaji

    Hi Arunkumar,
                               I think you are not clear.My question is can I use innerjoin with
    for all entries.For example below is my code.
    SELECT A~MATNR
             B~MAKTX
             A~MTART
             A~MATKL
             FROM MARA AS A INNER JOIN MAKT AS B
             ON AMATNR = BMATNR
             INTO TABLE IT_MARA_MAKT
             FOR ALL ENTRIES IN IT_MATNR
             WHERE A~MATNR = IT_MATNR-MATNR
             AND   A~EXTWG = P_EXTWG
             AND   A~SPART = P_SPART.
    Can we use like this for all entries along with innerjoins.
    Thanks,
    Balaji

  • Help needed in rewriting the code using inner joins

    Hi all,
    I need help in rewriting this code
    DATA :  FLD LIKE ZTABLE-ZFLD,
            FLD1 LIKE ZTABLE2-ZFLD2.
    select single ZFLD from zTABLE1 into FLD
                            where MATNR  = '123' and
                                  werks = 'ABC'.
    select single ZFLD1 from zTABLE2 into FLD1
                            where  zFLD = FLD.    
    iS there way that we can write this with inner joins
    Thanks

    Hi,
    help me out
    TABLE 1 HAS
    MATNR , WERKS , FLD1.
    TABLE 2 HAS
    FLD1, FLD2.
    I KNOW MATNR AND WERKS BASED ON THAT I HAVE TO GET FLD2
    I WANT IT BE WRITTEN WITH INNEWR JOINS
    WITH FOLLOWING COD E I GET AN ERROR MESSAGE SAYING
    comma without preccing colon (after select?)
    data : FLD1 like zTABLE1-ZFLD1.
    data : FLD2 like ZTABLE2-ZFLD2.
    SELECT FZFLD1 BZFLD2
        INTO ( FLD1, FLD2)
        FROM ZTABLE1 AS F INNER JOIN ZTABLE2 AS B
               ON FZFLD1 = BFLD2
        WHERE F~MATNR = '123'
          AND F~WERKS   = 'ABC' .
    Thanks

Maybe you are looking for

  • Unable to login into BIP using IIS/Oc4j

    Hi , we have configured SSO in OBIEE using IIS. and to configure oracle proxy for OC4J followed the steps at below url. http://gerardnico.com/wiki/dat/obiee/iis But getting the error when trying to browse the ulr http://localhost/xmlpserver/login.jsp

  • Unable to enter Recovery Mode for my iPad Air

    Unable to enter Recovery Mode for my iPad Air While updating my iPad Air to iOS 7.0.6, it went into an endless loop of cycling between the white Apple screen and the whirling dashes. I can't even reliably shut it down.  It seems a prime candidate for

  • Disk Utility - Solution for a Weird MediaKit Partition "too small" Error

    I found a very suggestive article, could be a silver bullet for this kind of problem. *http://ubuntuforums.org/showthread.php?t=760190* +*quote from SWedd*+ +In my case, it was caused by the Apple_Bootstrap partition (created during Ubuntu install),

  • Where can I set the "var" varibale in Flash CS4?

    Hi, I have seen one tutorial where in Text property there is option to define the Variable. I would like to make the digital clock using that tutorial. Where can I find the "var" option to define the variable name? Thanks.

  • Uni wifi

    my ipad wont connect to my uni wifi, other peoples do when i have all the settings done correctly to the unis fact sheet when i open safari the secure website login window does not open