Inner join Statement

Hi All,
I am using this inner Join Statement
      SELECT *
      FROM vbap AS a INNER JOIN vbak AS b
                     ON avbeln = bvbeln
                     AND amandt = bmandt
      WHERE a~vbeln IN lr_vbeln AND
            a~posnr IN lr_posnr AND
            a~aedat IN lr_aedat AND
          ( b~vbtyp EQ 'A' OR
            b~vbtyp EQ 'B' OR
            b~vbtyp EQ 'G' ).
But when i see the Output, One of the field ERDAT is geeting picked up from VBAK table instead of VBAP table.
Any pointers on how can we select the ERDAT from VBAP using this inner Join.
I dont want to use 2 select stetements.
Regards,
Mayank

In Inner join, it is always advisable to put the header table as First table and secondly, it should be advisable to fetch only the requried fields. I believe that you might not required all the fields of VBAP table.
Select A~Vbeln
          A~vbtyp
          B~posnr
          B~erdat
          into table I_VBAP
          from vbak as A innner Join VBAP as B
          on  a~vbeln = b~vbeln
          where   a~vbeln IN lr_vbeln AND
                      b~posnr IN lr_posnr AND
                      b~aedat IN lr_aedat AND
                     ( a~vbtyp EQ 'A' OR
                       a~vbtyp EQ 'B' OR
                       a~vbtyp EQ 'G' ).

Similar Messages

  • Inner join statement correction

    For three different tables we can write select statement like below?if any correction pleas correct it.
    select *
        from ekko as a
        inner join ekpo as b
          on  aebeln = bebeln
          inner join ekkn as c
           on  bebeln = cebeln
        into corresponding fields of table gt_data
        where a~zvoyn in s_zvoyn
          and a~ekgrp in s_ekgrp
          and a~ebeln in s_ebeln
          and a~zbookref2 in s_bookr
          and a~lifnr in s_lifnr
          and a~waers in s_waers
          and b~matnr in s_matnr
          and c~kostl in s_kostl..

    HI Venkee,
    Yes this query will work but to improve the performance
    use the required field names in the order as they are in the table instead of ' * '
    declare an internal table with this fields. assume gt_data
    and
    avoid using into corresponding.
    Regards,
    Md Ziauddin.

  • Using the max function in a inner joined statement

    I am trying to take from a database with two joined tables various datas from the record belonging to paul that has the highest entry number.
    String query = "SELECT Table1.name, Table1.idNumber, Table2.Address Table2.entryNum FROM Table1 INNER JOIN Table2 ON Table1.idNumber = Table2.idNumber WHERE Table2.entryNum = max ( Table2.entryNum) AND Table1.name = 'Paul'";
    The error message i get is.
    Cannot have aggregate function in WHERE clause
    Thanks for any help

    I am trying to take from a database with two joined
    tables various datas from the record belonging to paul
    that has the highest entry number.SELECT
    Table1.name,
    Table1.idNumber,
    Table2.Address
    Table2.entryNum
    FROM Table1 INNER JOIN Table2 ON Table1.idNumber = Table2.idNumber
    WHERE Table2.entryNum =
    ( select max( Table2.entryNum) from table1, table2
    where table1.idNumber=table2.idNumber
    AND Table1.name = 'Paul'" );

  • Alternative way for double inner join statement

    SELECT SINGLE ALNUM INTO P_ITAB-ALNUM_AL FROM  MAEX
             JOIN MARC ON MARCMATNR = MAEXMATNR
             JOIN T001W ON T001WWERKS = MARCWERKS
                 WHERE  MAEX~MATNR  = P_VBPLP-MATNR
                 AND    MARC~WERKS  = T_VBDPL-WERKS
                 AND    MAEXALAND  = T001WLAND1
                 AND    MAEX~GEGRU  = 'DE'.
    can any one suugest the best way to modify the above statement to improve the performence.
    Thanks,
    khasim.

    Hi,
    SELECT SINGLE ALNUM INTO P_ITAB-ALNUM_AL FROM MAEX
    JOIN MARC ON MAEX~MATNR = MARC~MATNR
    JOIN T001W ON MAEX~ALAND = T001W~LAND1
    WHERE MAEX~MATNR = P_VBPLP-MATNR
    AND MAEX~GEGRU = 'DE'.
    AND MARC~WERKS = T_VBDPL-WERKS
    AND T001W-WERKS = T_VBDPL-WERKS.
    I have made the WHERE clause free from the comparison of two table fields and changed the second JOIN. The selection criteria, however is same as the SELECT query provided by you.
    Try this query and positively let me know about its performance.
    Regards,
    Jayesh

  • Inner join with if statement , how to combine these code ?

    Hello everyone, I have 2 group of code here. This 2 group of code is working without error. But I face a problem , I need to group up this 2 group of code. Please take a look, thank you This is the first code i create.
    SELECT r.Name , r.Restaurant_ID, f.feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
        s.State_ID, s.State, l.Location_ID, l.Area, l.State_ID, r.Name, r.Location_ID
    FROM Restaurants r, Bridge1_Restaurant_Features b, Features f, Cuisine c, State s, Location l
            where 0=0
            AND b.Feature_ID = f.Feature_ID
            AND b.Restaurant_ID = r.Restaurant_ID
            AND r.Cuisine_ID = c.Cuisine_ID
            AND r.Location_ID = l.Location_ID
            AND l.State_ID = s.State_ID
            <cfif ARGUMENTS.Feature_ID IS NOT "">
            AND b.Feature_ID IN (#ARGUMENTS.Feature_ID#)
            </cfif>
            <cfif ARGUMENTS.Price_Range IS NOT "">
            AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
            </cfif>
            <cfif ARGUMENTS.Cuisine IS NOT "">
            AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
            </cfif>
            <cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
            AND l.State_ID = #val(ARGUMENTS.LocationID2)#
            <cfelse>
                AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
            </cfif>
    Then, I notice the feature_ID i need to use another logic to show the result. The code is like this
    SELECT r.Restaurant_ID, r.Name, f.Feature
    FROM   Restaurants r
    INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
    INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
    INNER JOIN
         SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
         FROM   Bridge1_Restaurant_Features
         <!--- find matching features --->
         WHERE  Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
        GROUP BY Restaurant_ID
        <!--- having ALL of the requested features --->
         HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
    ) ck ON ck.Restaurant_ID = r.Restaurant_Id
    I want combine this 2 group together. The second group have to replace
    <cfif ARGUMENTS.Feature_ID IS NOT "">
        AND f.Feature_ID IN (#ARGUMENTS.Feature_ID#)
    </cfif>
    I try few way to group this 2 code, but fail to make it. The code i try is on below, it get error.
    SELECT r.Name , r.Restaurant_ID, f.feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
            s.State_ID, s.State, l.Location_ID, l.Area, l.State_ID,  r.Location_ID
            FROM Restaurants r, Features f, Cuisine c, State s, Location l
            INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
            INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
            AND r.Cuisine_ID = c.Cuisine_ID
            AND r.Location_ID = l.Location_ID
            AND l.State_ID = s.State_ID
            <cfif ARGUMENTS.Feature_ID IS NOT "">
            INNER JOIN
                 SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
                 FROM   Bridge1_Restaurant_Features
                 <!--- find matching features --->
                 WHERE  Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
                GROUP BY Restaurant_ID
                <!--- having ALL of the requested features --->
                 HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
            ) ck ON ck.Restaurant_ID = r.Restaurant_Id
            </cfif>
            <cfif ARGUMENTS.Price_Range IS NOT "">
            AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
            </cfif>
            <cfif ARGUMENTS.Cuisine IS NOT "">
            AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
            </cfif>
            <cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
            AND l.State_ID = #val(ARGUMENTS.LocationID2)#
            <cfelse>
                AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
            </cfif>

    Yeah Adam I am listen to you ! But Finally i solve it.
    This is the code i solve .
    SELECT r.Restaurant_ID, r.Name, f.Feature, r.Price_Range, r.Cuisine_ID, c.Cuisine,
                        l.Location_ID, l.Area, s.State
              FROM   Restaurants r
              <cfif ARGUMENTS.Feature_ID IS NOT "">
              INNER JOIN
                   SELECT Restaurant_ID, COUNT(Feature_ID) AS FeatureCount
                   FROM   Bridge1_Restaurant_Features
                   <!--- find matching features --->
                   WHERE  Feature_ID IN ( <cfqueryparam value="#ARGUMENTS.Feature_ID#" cfsqltype="cf_sql_integer" list="true"> )
                  GROUP BY Restaurant_ID
                  <!--- having ALL of the requested features --->
                   HAVING COUNT(Feature_ID) = <cfqueryparam value="#listLen(ARGUMENTS.Feature_ID)#" cfsqltype="cf_sql_integer">
              ) ck ON ck.Restaurant_ID = r.Restaurant_Id
              </cfif>
              INNER JOIN Location l ON r.Location_ID = l.Location_ID
              INNER JOIN State s ON l.State_ID = s.State_ID
              INNER JOIN Cuisine c ON r.Cuisine_ID = c.Cuisine_ID
              INNER JOIN Bridge1_Restaurant_Features b ON b.Restaurant_ID = r.Restaurant_ID
              INNER JOIN Features f ON b.Feature_ID = f.Feature_ID
              <cfif ARGUMENTS.Cuisine IS NOT "">
              AND r.Cuisine_ID = (#ARGUMENTS.Cuisine#)
              </cfif>
              <cfif ARGUMENTS.Price_Range IS NOT "">
              AND r.Price_Range IN (#ARGUMENTS.Price_Range#)
              </cfif>
              <cfif val(ARGUMENTS.LocationID2) IS #val(ARGUMENTS.StateID)#>
              AND l.State_ID = #val(ARGUMENTS.LocationID2)#
              <cfelse>
                   AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
              </cfif>
    Is it the code can be improve more ?

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

  • Inner Join.

    I am using a Inner join statement. I dont see any problem in DEV but i see some problems in PMT. IT duplicating the records in the output. I see the same order twice.
    The statement is,
        SELECT plaf~plnum
               maranormt  plafmatnr
               makt~maktx                                      
               plafpwwrk  plafpaart  plaf~verid
               plafauffx  plafpsttr  plafgsmng plafplscn
          INTO TABLE t_plaf
          FROM plaf
         INNER JOIN mara
            ON plafmatnr EQ maramatnr
         INNER JOIN makt                                       
            ON maramatnr EQ maktmatnr                        
           FOR ALL entries IN t_mara
         WHERE plaf~matnr = t_mara-matnr.
    However i looked into the MAKT table. I see 2 descriptions for the same material no.
    I am assuming thats the problem.
    ANy suggestions.
    Ster.

    > Hello,
    >
    >  Check this code . I tried it now and it's working
    >
    >
    > Tables: plaf,mara,makt.
    >
    > Data: it_plaf type standard table of plaf.
    > data: it_mara type standard table of mara,
    >       it_makt type standard table of makt.
    > ct-options: s_plnum for plaf-plnum,
    >                 s_matnr for mara-matnr.
    > plaf into table it_plaf
    >          where plnum in s_plnum
    > and matnr in s_matnr.
    >
    > if it_plaf[] is not initial.
    >
    >    select * from mara into table it_mara
    >        for all entries in it_plaf
    >    where matnr = it_plaf-matnr.
    >  Select * from makt into table it_makt
    >          for all entries in it_plaf
    >  where matnr = it_plaf-matnr.
    >
    > endif.
    >
    > Loop at it_mara into wa_mara.
    > read table it_plaf into wa_plaf with key matnr =
    > wa_mara-matnr.
    > if sy-subrc = 0.
    > move-corresponding to wa_final.
    > endif.
    > read table it_makt into wa_makt witk key matnr =
    > wa_mara-matnr.
    > if sy-subrc = 0.
    > Move-corresponding to wa_final.
    > endif.
    > append wa_final to it_final.
    > clear: wa_mara,wa_plaf,wa_final.
    > endloop.
    >
    >
    > Regards,
    > Deepu.K
    It would be better for performance to use Field-Symbols -;)
    FIELD-SYMBOLS: <MARA> LIKE LINE OF IT_MARA.
    Loop at it_mara into <MARA>.
    *Process data....
    endloop.
    Greetings,
    Blag.

  • Help with Inner join problem

    The following query works fine as long as there is a value in the subID field, which is at the end of the inner join statement. If the subID is blank then no data is output, even though it is there. Try as I may, I can not get the right solution in the where statement to get the data to show without the subID. What am I missing?
    <cfquery name="getInfo" datasource="#application.database#">
    select page_id, pageName, pages.content, pages.cat_id, pages.seo_title,pages.seo_desc,pages.seo_words,pages.h1_title,pages.pic,pages.brochure,pa ges.video,catagories.catagory,subcat.subID,subcat.sub_category
    from (pages INNER JOIN catagories ON pages.cat_id = catagories.cat_id) INNER JOIN subcat ON pages.subID = subcat.subID
    where pages.page_id = #page_id#
    </cfquery>

    Rick,
    Looks like you need a LEFT OUTER join to the "subcat" table, so that all records for "pages" and "catagories" are returned even if no matching "subcat" records exist.  INNER joins will only return selected records when the tables on both sides of the join statement have matching values, while a LEFT OUTER (sometimes also known simply as a LEFT join) join will return *all* selected records from the table(s) on the left side of the join statement regardless of whether there are matching records from the table on the right side of the join statement.  When there are no matching records from the table on the right side of the join statement, any columns in your SELECT clause that are from the table on the right side of the join statement will contain NULLs.
    HTH,
    -Carl V.

  • Avoiding inner joins????

    Hi all,
    I was just thinking of ways to improve the perfomance of my report. Its fetching data in to two different tables using two innerjoins and these two internal tables are again looped for some other manipulation. Can anyone tell me the ways i can avoid innerjoin or is there other ways to improve psrfomance by avoiding innejoins in general?
    Rakesh

    hi sir i was able to find out that
    Using several nested INNER JOIN statements can be inefficient and cause time out if the tables become too big in the future."
    Joins here (in ABAP) are not those Native SQL Joins.  If you are talking about the Core RDBMS, which mean Oracle or SQL Server, then Undoubtedly Joins are the best.
    In ABAP, these joins are first split by the ABAP processor and then sent to the database, with the increase in DATA in production system, these joins tend to give way if your database keeps growing larger and larger.
    You should rather used "FOR ALL ENTRIES IN" (Tabular conditions), which is a much effecient way as far as performance is concerned.
    For example :
    DATA: BEGIN OF LINE,
            CARRID   TYPE SPFLI-CARRID,
            CONNID   TYPE SPFLI-CONNID,
            CITYFROM TYPE SPFLI-CITYFROM,
            CITYTO   TYPE SPFLI-CITYTO,
          END OF LINE,
          ITAB LIKE TABLE OF LINE.
    LINE-CITYFROM = 'FRANKFURT'.
    LINE-CITYTO   = 'BERLIN'.
    APPEND LINE TO ITAB.
    LINE-CITYFROM = 'NEW YORK'.
    LINE-CITYTO   = 'SAN FRANCISCO'.
    APPEND LINE TO ITAB.
    SELECT CARRID CONNID CITYFROM CITYTO
    INTO   CORRESPONDING FIELDS OF LINE
    FROM   SPFLI
    FOR ALL ENTRIES IN ITAB
    WHERE  CITYFROM = ITAB-CITYFROM AND CITYTO = ITAB-CITYTO.
      WRITE: / LINE-CARRID, LINE-CONNID, LINE-CITYFROM, LINE-CITYTO.
    ENDSELECT.
    Do you have a ABAP Question?
    Best regards,
    SAP Basis, ABAP Programming and Other IMG Stuff

  • Reports - Inner Joins

    Dear Friends,
    I need to prepare a classic report based on the following parameters :
    I would like to know, how to join these three tables using Inner Joins - MARA, MARC, MSTA.
    I should be able to view the fields from these tables.
    I tried out with the common fields from these tables, viz. MARA - MATNR - MARC, MARC - WERKS - MSTA.
    I would appreciate, if anyone replies me with the select statement using the above mentioned tables using Inner Joins statement with any common fields .
    Thanking you in anticipation.

    Dear dinesh kumar
    1. We can join the three tables with matnr field.
    2. WERKS has to be provided from the program - (plant).
       ie. For which plant, data is required.
    3. Due to MSTA table, you may get multiple records
       for same MATNR. bcos of maintenance records
       by different departments in MSTA Table.
    If it helps, pls give points.
    REPORT abc.
    data : begin of itab occurs 0,
           matnr like mara-matnr,
           "---- Other Fields
           end of itab.
    data : matnr like mara-matnr.
    data : werks like marc-werks.
    Query
    select a~matnr
    into table itab
    from mara  as a
    inner join marc as b
    on amatnr = bmatnr
    inner join msta as c
    on amatnr = cmatnr
    Required Conditions From Program
    where a~matnr = matnr
    and b~werks = werks.
    Thanks & Regards,
    Amit Mittal.

  • Re field order in INNER JOIN

    Hi,
    I need a suggestion for improvement of my inner JOIN statement.
    internal table itab is of below type
    type: begin of ty_itab
            field a
            field b
            field c
            field d
            end of ty_itab
    I have to join two database table TABLE1 and TABLE2. Fields a and d are from TABLE2 and fields b and c are from TABLE 1.
    But in the internal table I must have the fields in the order fielda,b,c,d.
    Which of the below two options will be better for performance ? And why ?
    option 1:
    SELECT tab2~a
                  tab1~b
                  tab1~c
                  tab2~d into corresponding fields of itab from TABLE1 as tab1 and TABLE2 as tab2 on..........
    option2:
    SELECT tab1~b
                  tab1~c
                  tab2~a 
                  tab2~d into corresponding fields of itab from TABLE1 as tab1 and TABLE2 as tab2 on..........
    Thanks in advance...
    Best Regards
    Ananya Mukherjee
    Moderator message - Cross post locked
    Edited by: Rob Burbank on May 28, 2009 9:43 AM

    I am not satisfied with your two options. Because of following reason,
    1. First I want to know which one is master table and item table. Because in inner join select query you want to use master table as first and you want to use the item table as second.
    Example: 
    SELECT TAB2A  TAB1B TAB1C TAB2D
          INTO TABLE ITAB
        FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
    2. You should not use the INTO CORRESPONDING FIELDS OF ITAB. Instead of this you can change the field order in internal table or in select query.
    Example:
    Use following way
    TYPE: BEGIN OF TY_ITAB
                    FIELD A
                    FIELD B
                    FIELD C
                    FIELD D
               END OF TY_ITAB
    SELECT TAB2A  TAB1B TAB1C TAB2D
         INTO TABLE ITAB
       FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
    Or , Anyway you are going to use in program only. It will not affect your logic if change the field order in the internal table.
    TYPE: BEGIN OF TY_ITAB
                    FIELD B
                    FIELD C
                    FIELD A
                    FIELD D
              END OF TY_ITAB
    SELECT TAB1B  TAB1C  TAB2A  TAB2D
         INTO TABLE ITAB
       FROM <MASTER TABLE1> AS TAB1 INNER JOIN <ITEM TABLE2> AS TAB2 ON..........
    3. In inner join query, the order of Where condition also create the perform issue. Because in where condition maximum you try to use all the primary key from <MASTER TABLE1>  and <ITEM TABLE2> and field order in where condition should be same order in <MASTER TABLE1>  and  <ITEM TABLE>.
    This are the things you want to take care when you try to use INNER JOIN Query. If you have any clarification please let me know. I will try answer your Questions.
    Ravi.
    Edited by: RavivarmanP on May 28, 2009 6:55 PM

  • Dynamic Inner Join in 4.6c

    Requirement is dynamic specification of  Table name in inner join. The table names to be used in join would be derived in a variable using select statement. These names to be supplied to join dynamically. The other join conditions and where conditions will remain same.
    For example :
    On the basis of 1st select statement tables names are fetched in 2 variables tab1 & tab2.
    Now want to use these two variables in inner join statement.
    Searched and as per few example tried to do in following manner but its not working
    data: tab1(10) type c value 'MARA',
            tab2(10) type c value 'MAKT'.
    data: dbtab1(10) type c,
             dbtab2(10) type c .
    dbtab1 = tab1. 
    dbtab2 = tab2. 
    DATA: BEGIN OF itab occurs 0,
               matnr TYPE mara-matnr,
               maktx type makt-maktx,
    END OF itab.
    DATA: column_syntax TYPE string,
                dbtab_syntax TYPE string.
    PARAMETERS: p_matnr TYPE mara-matnr.
    dbtab_syntax = '( (dbtab1) AS t1 '
    &' INNER JOIN (dbtab2) AS t4 ON t1~MATNR = t4~MATNR )'.
    SELECT  matnr maktx
    FROM (dbtab_syntax)
    INTO TABLE itab  WHERE t4~matnr   = p_matnr.
    Got the following error:
    "A table name, specified in an SQL command, is unknown"
    It seems not able to identify table name dynamiccaly in dbtab_syntax.
    thanks
    anya
    Edited by: Thomas Zloch on Nov 29, 2010 10:18 AM - please use code tags

    Hi Anya,
    Following code will be work
    CONCATENATE dbtab1 ' as t1 INNER JOIN ' dbtab2 ' as t4 ON t1MATNR = t4MATNR ' INTO dbtab_syntax RESPECTING BLANKS.
    TRANSLATE dbtab_syntax TO UPPER CASE.
    SELECT  t1~matnr maktx
    FROM (dbtab_syntax)
    INTO TABLE itab  WHERE t4~matnr   = p_matnr.
    Note the following point
    1) Don't used un-necessary bracket inside the SQL.
    2) Specify alias name or table name when fields exit in both table while projection.
        i.e. SELECT  matnr maktx will be now SELECT  t1~matnr maktx

  • Inner join select

    I had my data declaration as below.
    DATA :BEGIN OF t_plaf OCCURS 0,
           normt LIKE mara-normt,
           matnr LIKE plaf-matnr,
           pwwrk LIKE plaf-pwwrk,
           paart LIKE plaf-paart,
           verid LIKE plaf-verid,
           auffx LIKE plaf-auffx,
           psttr LIKE plaf-psttr,
           gsmng LIKE plaf-gsmng,
          END OF t_plaf.
    corresponding inner join statement
      SELECT maranormt  plafmatnr
             plafpwwrk  plafpaart  plaf~verid
             plafauffx  plafpsttr  plaf~gsmng
        INTO TABLE t_plaf
        FROM plaf
       INNER JOIN mara
          ON plafmatnr EQ maramatnr
       WHERE plaf~paart = 'LA'.
    Now I have changed the declaration as below
    DATA : BEGIN OF t_plaf OCCURS 0,
           normt LIKE mara-normt.
            INCLUDE STRUCTURE plaf.
    DATA : END OF t_plaf.
    now i have changed the data declaration as mentioned above and need a inner join statement for the data declaration i have specified.
    Any suggestions,
    MAdhu

    Hi Madhu,
    USE INTO CORRESPONDING option instead of INTO TABLE.
    SELECT maranormt plafmatnr
    plafpwwrk plafpaart plaf~verid
    plafauffx plafpsttr plaf~gsmng
    <b>INTO CORRESPONDING FIELDS OF TABLE t_plaf</b>
    FROM plaf
    INNER JOIN mara
    ON plafmatnr EQ maramatnr
    WHERE plaf~paart = 'LA'.
    Thanks,
    Vinay

  • How to  Join two tables using the Inner Join

    Hi All,
    I have two tables i.e table1 and table2 as i have created two otds and my present requirement is to join this two tables and get the results and using this i need to do some logic and update another table3.
    can some one help me out how to go for the above req.
    Thanks in Advance
    Srikanth

    The best efficient way to use inner join is create two input otds,use there otd's in create a collaboration usinf etl.
    after selecting two input otd's create a inner join statement and map it to out put otd.
    while using the etl the performance of the over all integration is increased 20 time of the normal integration.
    Hopes this will helps,,
    Thanks,
    Papa Rao.

  • Inner joins  Vs  for all entries

    Hi All,
    Pls let me know
    the differences b/w innerjoins and for all entries,,,,which is the best option and  Y??
    Thanks in Advance,
    Bye

    Hi!
    INNER JOIN is used if we want to retrieve some data from more than one table.
    FOR ALL ENTRIES is used if we want some data from a table based on some conditions of some other table.
    Using several nested INNER JOIN statements can be inefficient and cause time out if the tables become too big in the future."
    In ABAP, these joins are first split by the ABAP processor and then sent to the database, with the increase in DATA in production system, these joins tend to give way if your database keeps growing larger and larger.
    You should rather use "FOR ALL ENTRIES IN" (Tabular conditions), which is a much efficient way as far as performance is concerned.
    Check these links:
    inner joins and for all entries
    inner join and for all entries
    Reward points if it helps.
    Regards
    Sudheer

Maybe you are looking for

  • Oracle Fusion Order Demo Application

    Hi, I downloaded this DEMO : Oracle Fusion Order Demo Application http://www.oracle.com/technetwork/developer-tools/jdev/index-095536.html And when in step 9.In the application navigator, under the Resources node, Right click build.xml and choose Run

  • Portal development

    I am creating a page with several Regions. I need to be able to create Trees and List objects on my page. I need to create Directory structures with Regions as well. I need to be able to create links as well. I need to know how to gain access to my D

  • Empty Import Structure in RFC

    Hi, I have created a RFC Adapter for receiving XML files. After some problems about the starting of the function module that are already solved now I have another request. My FM is running ok but I've a problem with the imported structure. ½ Hà„:P/ԃ

  • How to upgrade from 10.4.11 to a OS.5?

    I read the previously posted question re info on same topic but it did not answer my question. What exactly must I do to upgrade as stated in my question? I received something on desktop named mackeeper pkg but I cannot open the download because my s

  • BIBean poor performance when using Query.setSuppressRows()

    Does anyone have experience in suppressing N/A cell values using BIBean? I was experimenting the use of Query.setSuppressRows(DataDirector.NA_SUPPRESSION). It does hide the rows that contains N/A values in a crosstab. The problem is that the performa