Inner join query used with 7 Database tables

HI All,
In a report they used the Inner join Query with 6 Data base table..now there is a performance issue with at query.
its taking so much of time to trigger that query. Please help how to avoid that performance issue for that.
In that 2 database tables containing lakhs of records..
According to my knowledge it can be avoided by using secondary indexs for those 2 database tables..
and by replacing the Inner join Query with FOR ALL ENTRIES statement.
i want how to use the logic by using FORALL ENTRIES statement for this..
So, please give you proper suggestion to avoid this issue..
Thanking you.
Moderator message: Please Read before Posting in the Performance and Tuning Forum
Edited by: Thomas Zloch on Oct 16, 2011 10:27 PM

Hi,
And what do you mean with "they used"? If "SAP used" then yo will need to ask a SAP for note
FOR ALL ENTRIES is quite good described in help. Please search forum also.
Without query it won't be possible to tell how it can be optimized, however you can try to use SE30/SAT and ST05. Maybe it will help you.
BR
Marcin Cholewczuk

Similar Messages

  • MV Incremental Refresh on join query of remote database tables

    Hi,
    I am trying to create a MV with incremental refresh option on a join query with 2 tables of remote database.
    Created MV logs on 2 tables in the remote database.
    DROP MATERIALIZED VIEW LOG ON emp;
    CREATE MATERIALIZED VIEW LOG ON emp WITH ROWID;
    DROP MATERIALIZED VIEW LOG ON dept;
    CREATE MATERIALIZED VIEW LOG ON dept WITH ROWID;
    Now, trying to create the MV,
    CREATE MATERIALIZED VIEW mv_emp_dept
    BUILD IMMEDIATE
    REFRESH FAST
    START WITH SYSDATE
    NEXT SYSDATE1/(24*15)+
    WITH PRIMARY KEY
    AS
    SELECT e.ename, e.job, d.dname FROM emp@remote_db e,dept@remote_db d
    WHERE e.deptno=d.deptno
    AND e.sal>800;
    Getting ORA-12052 error.
    Can you please help me.
    Thanks,
    Anjan

    Primary Key is on EMPNO for EMP table and DEPTNO for DEPT table.
    Actually, I have been asked to do an feasibility test whether incremental refresh can be performed on MV with join query of 2 remote database tables.
    I've tried with all combinations of ROWID and PRIMARY KEY, but getting different errors. From different links, I found that it's possible, but cannot create any successful testcase anyway.
    It will be very much helpful if you can correct my example or tell me the restrictions in this case.
    Thanks,
    Anjan

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • How can I perform this kind of range join query using DPL?

    How can I perform this kind of range join query using DPL?
    SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
    In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
    It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.

    I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
    Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
    This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
    An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
    If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
    Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Inner Join. How to improve the performance of inner join query

    Inner Join. How to improve the performance of inner join query.
    Query is :
    select f1~ablbelnr
             f1~gernr
             f1~equnr
             f1~zwnummer
             f1~adat
             f1~atim
             f1~v_zwstand
             f1~n_zwstand
             f1~aktiv
             f1~adatsoll
             f1~pruefzahl
             f1~ablstat
             f1~pruefpkt
             f1~popcode
             f1~erdat
             f1~istablart
             f2~anlage
             f2~ablesgr
             f2~abrdats
             f2~ableinh
                from eabl as f1
                inner join eablg as f2
                on f1ablbelnr = f2ablbelnr
                into corresponding fields of table it_list
                where f1~ablstat in s_mrstat
                %_HINTS ORACLE 'USE_NL (T_00 T_01) index(T_01 "EABLG~0")'.
    I wanted to modify the query, since its taking lot of time to load the data.
    Please suggest : -
    Treat this is very urgent.

    Hi Shyamal,
    In your program , you are using "into corresponding fields of ".
    Try not to use this addition in your select query.
    Instead, just use "into table it_list".
    As an example,
    Just give a normal query using "into corresponding fields of" in a program. Now go to se30 ( Runtime analysis), and give the program name and execute it .
    Now if you click on Analyze button , you can see, the analysis given for the query.The one given in "Red" line informs you that you need to find for alternate methods.
    On the other hand, if you are using "into table itab", it will give you an entirely different analysis.
    So try not to give "into corresponding fields" in your query.
    Regards,
    SP.

  • Regarding Inner join query

    Hi Guriji,s
    I wrote one inner join query. it is working fine. but when i exceute this query it is fetching the data only 261 movement type but but i also fetch the data movement type 201. for this plz tell me the correction in this query.
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
          on amblnr = bmblnr
             where awerks in plant and  abwart =  '261' or a~bwart = '201'
           and  btcode2 = 'mb1a' or btcode2 = 'mfbf' .
    thanks.

    Hi Sachin
    try to use like below
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
    on amblnr = bmblnr
    where awerks in plant and  ( abwart = '261' or a~bwart = '201' )
    and  ( btcode2 = 'mb1a' or btcode2 = 'mfbf' ).
    or try to fill ranges like select-options or use like
    select amatnr awerks abwart bbudat into table t_itab from mseg as a inner join mkpf as b
    on amblnr = bmblnr
    where awerks in plant and  abwart in ('261', '201')
    and btcode2 = 'mb1a' or btcode2 = 'mfbf' .
    Regards
    Praveen

  • ADF Query Panel with Tree Table -- Add Fields

    I created ADF Query Panel with Tree Table using JDeveloper 11G. Under Advance Search, Add Fields pull down only list the fields in the master table. My questions are,
    1) Can I search fields in detail table? If yes, how can I do it?
    2) How can I customized this pull down list? Currently it just show the entire view of master table with unnecessary id type data.
    Thanks in advance.
    Edited by: kxc on Nov 9, 2009 9:21 AM

    1) Can I search fields in detail table? If yes, how can I do it?
    Are there anyway to search the second level node?You can. But you need to evaluate if the arrangement works for you.
    I assume you have a view link from the master to detail VO.
    To do so, in your master view criteria (the one which you use in the query panel), shuttle the attributes of your detail VO (in master attributes list, you'l see the detail view link accessor - on selecting this, the detail atteributes are available to you)
    In the Add Fields, it shows as student_id AND student_name. I was unable to delete the student_id field in the view since it is PKYou can set its 'display' UI hint to 'hide' in your VO.

  • Tool to create Java Object classes using the Database Tables

    Hi,
    Is their any tools or utility available to create the Java Object Classes using the Database Tables as input.
    Lets Say I am having the Employee, Employee_Salary tables in the Database.The utility has to create the Java Object classes with the relation.
    Please Help...
    Thx..

    Hm, for generating regular Java classes I wouldn't know one from memory. But I suggest you start searching in for example the Eclipse marketspace for a third party plugin that can do it. If all fail, you could always use Hibernate Tools from the Jboss Tools Eclipse plugin set to generate Hibernate/JPA entities and then strip the annotations from them to turn them into regular POJO classes.
    How many tables are we talking about anyway? It might be less effort to just create the classes with properties and then use an IDE to generate getters and setters for them.

  • Query in abap database tables

    hello Experts,
       Is there any System table to get the Year.For Example to get the Month we can use T247 database table like this any system table to get year.
    thanks
    regards,
    Ashok.

    Sorry can you explain what do you mean to get year ??
    The below would give you the year.
    Year = Sy-datum(4).
    If you wish to convert it into words you can use SPELL_WORD and make sure to use currency with zero decimails..in that case it would return two thousand six in words.

  • Error binding table components with database tables

    Hi, when i try to bind table components with database tables y receive this error
    java.lang.NullPointerException
         at com.sun.sql.rowset.CachedRowSetXImpl.initMetaData(CachedRowSetXImpl.java:861)
         at com.sun.sql.rowset.CachedRowSetXImpl.getMetaData(CachedRowSetXImpl.java:2336)
         at com.sun.data.provider.impl.CachedRowSetDataProvider.getMetaData(CachedRowSetDataProvider.java:1317)
         at com.sun.data.provider.impl.CachedRowSetDataProvider.getFieldKeys(CachedRowSetDataProvider.java:489)
         at com.sun.rave.web.ui.component.table.TableRowGroupDesignState.resetTableColumns(TableRowGroupDesignState.java:261)
         at com.sun.rave.web.ui.component.table.TableRowGroupDesignState.setDataProviderBean(TableRowGroupDesignState.java:163)
         at com.sun.rave.web.ui.component.table.TableDesignState.setDataProviderBean(TableDesignState.java:250)
         at com.sun.rave.web.ui.component.TableDesignInfo.linkBeans(TableDesignInfo.java:162)
         at com.sun.rave.insync.models.FacesModel.linkBeans(FacesModel.java:1042)
         at com.sun.rave.designer.DndHandler.processLinks(DndHandler.java:2126)
         at com.sun.rave.designer.DndHandler.importBean(DndHandler.java:880)
         at com.sun.rave.designer.DndHandler.importItem(DndHandler.java:702)
         at com.sun.rave.designer.DndHandler.importDataDelayed(DndHandler.java:376)
         at com.sun.rave.designer.DndHandler.access$000(DndHandler.java:114)
    [catch] at com.sun.rave.designer.DndHandler$1.run(DndHandler.java:298)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    There are a thing that I don't undertand. When I try to bind samples database table (Travel, for example) to table components, there are no errors. But when I try to bind table component with my remote postgresql database table, yes...the table component disappear and only a "Table" string is displayed....this error is because I use remote database?? Or because it's PostgreSQL??
    Thanks.

  • I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY WUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ??

    I HAVE A SOURCE TABLE WITH 10 RECORDS AND TARGET TABLE 15 RECORDS. MY QUESTION IS USING WITH THE TABLE COMPARISON TRANSFORM .I WANT TO DELETE UNMATCHED RECORDS FROM THE TARGET TABLE ?? HOW IT IS ??

    Hi Kishore,
    First identify deleted records by selecting "Detect deleted rows from comparison table" feature in Table Comparison
    Then Use Map Operation with Input row type as "delete" and output row type as "delete" to delete records from target table.

  • Help with SQL Query Involving Three Database Tables

    Hi,
    My SQL is very rusty since I have not touched it in over one year.
    I was given an SQL question in a job interview and I am curious to know the right answer.
    This was a pre-prepared written test and the interviewer did not know the answer.
    There are three database tables: STUDENTS, COURSES and STUDENT_COURSES
    Table STUDENTS has STUDENT_ID and STUDENT_NAME columns.
    Table COURSES has COURSE_ID and COURSE_DESCRIPTION columns.
    Table STUDENT_COURSES has columns STUDENT_ID and COURSE_ID.
    Provide a query that returns all the students that are enrolled in all the courses.
    Thanks,
    Avi.

    It is probably good to say that this task may be solved such way, if database normalized and there are references
    Basically here just is a variant of your solution
    DROP TABLE student_course;
    DROP TABLE student;
    DROP TABLE course;
    CREATE TABLE student
    (student_id NUMBER(9) PRIMARY KEY,
    student_name VARCHAR2(30));
    CREATE TABLE course
    (course_id NUMBER(9) PRIMARY KEY,
    dscr VARCHAR2(100));
    CREATE TABLE student_course
    (student_id NUMBER(9),
    course_id NUMBER(9));
    ALTER TABLE student_course
    ADD CONSTRAINT pk_st_crs PRIMARY KEY
    (student_id, course_id);
    ALTER TABLE student_course
    ADD CONSTRAINT fk_student
      FOREIGN KEY (student_id)
      REFERENCES student(student_id);
    ALTER TABLE student_course
    ADD CONSTRAINT fk_course
      FOREIGN KEY (course_id)
      REFERENCES course(course_id);
    INSERT INTO student
         VALUES (1, 'NAME1');
    INSERT INTO student
         VALUES (2, 'NAME2');
    INSERT INTO student
         VALUES (3, 'NAME3');
    INSERT INTO course
         VALUES (101, 'Desc 1');
    INSERT INTO course
         VALUES (102, 'Desc 2');
    INSERT INTO course
         VALUES (103, 'Desc 3');
    INSERT INTO student_course
         VALUES (1, 101);
    INSERT INTO student_course
         VALUES (1, 102);
    INSERT INTO student_course
         VALUES (2, 101);
    INSERT INTO student_course
         VALUES (2, 103);
    INSERT INTO student_course
         VALUES (3, 101);
    INSERT INTO student_course
         VALUES (3, 102);
    INSERT INTO student_course
         VALUES (3, 103);
    COMMIT ;
    WITH st_crs_cnt AS
         (SELECT   student_id,
                   COUNT (*) tot
              FROM student_course
          GROUP BY student_id)
    SELECT sc.student_id,
           sc.tot
      FROM st_crs_cnt sc
      WHERE sc.tot = (SELECT COUNT (*) FROM course);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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

  • Deciphering column names in a join query using jdbc

    hi all....
    I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
    i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
    all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
    Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
    Any pointers would be most appreciated.
    cheers
    vivek

    thanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
    this also puts me in a doubt whether i can use join in my case.
    for eg ... .
    lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
    Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
    select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
    this would return me 3 rows and i can also recognize various columns with their aliases ..
    but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
    this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
    Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
    i guess the only soln left is to visit contact and address table separately. :(

  • Help on Inner Join Query

    Hi ABAPers,
    I was trying to develop a report for which query is something like this.
    *& Report  ZT_SERIAL
    REPORT  ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS. " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
           OBKNR LIKE OBJK-OBKNR,     "OBJECT LIST
           OBZAE LIKE OBJK-OBZAE,     "OBJECT COUNTER
           KUNDE LIKE SER01-KUNDE,    "CUSTOMER NO
           MATNR LIKE OBJK-MATNR,     "PART NO
           SERNR LIKE OBJK-SERNR,     "SERIAL NO
           MBLNR LIKE SER03-MBLNR,    "GRN/MATERIAL DOC NO
           LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
           DATUM LIKE SER01-DATUM,    "OUTBOUND DELV DATE
           TASER LIKE OBJK-TASER,     "HEADER TABLE
           ANZSN LIKE SER01-ANZSN,    "NO OF SERIAL NOS
           VGBEL LIKE LIPS-VGBEL,     "SALES ORDER NO
           END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
                      S_VGBEL FOR LIPS-VGBEL,
                      S_MATNR FOR OBJK-MATNR,
                      S_SERNR FOR OBJK-SERNR,
                      S_MBLNR FOR SER03-MBLNR,
                      S_LIFNR FOR SER01-LIEF_NR,
                      S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM = SY-REPID
        I_GRID_TITLE       = I_TITLE_SL_NO_TRACK
        IS_LAYOUT          = LAYOUT
        IT_FIELDCAT        = P_FIELDTAB[]
        I_SAVE             = 'A'
        IT_EVENTS          = V_EVENTS
      TABLES
        T_OUTTAB           = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    SELECT OBJKOBKNR OBJKOBZAE OBJKMATNR OBJKSERNR OBJK~TASER
           SER01KUNDE SER01LIEF_NR SER01DATUM SER01ANZSN
           SER03~MBLNR
           LIPS~VGBEL
           INTO TABLE ITAB FROM OBJK
           INNER JOIN SER01 ON OBJKOBKNR = SER01OBKNR
           INNER JOIN SER03 ON OBJKOBKNR = SER03OBKNR
           INNER JOIN LIPS ON SER01LIEF_NR = LIPSVBELN
           WHERE
           OBJKTASER = 'SER01' OR OBJKTASER = 'SER03'.
           OBJK~MATNR IN S_MATNR AND
           OBJK~SERNR IN S_SERNR AND
           SER01~KUNDE IN S_KUNDE AND
           SER01~LIEF_NR IN S_LIFNR AND
           SER01~DATUM IN S_DATUM AND
           SER03~MBLNR IN S_MBLNR AND
           LIPS~VGBEL IN S_VGBEL.
    ENDFORM.
    *&      Form  fldcat
          text
    FORM FLDCAT.
      PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
      PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
      PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
      PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
      PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
      PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
      PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM.                    "fldcat
    *&      Form  fldcat1
          text
         -->FNAM       text
         -->FTEXT      text
    FORM FLDCAT1 USING FNAM FTEXT.
        DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
              L_FIELDCAT-FIELDNAME  = FNAM.
              L_FIELDCAT-SELTEXT_M = FTEXT.
      IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
        L_FIELDCAT-KEY = 'X'.
      ENDIF.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    CLEAR fldcat1.
    ENDFORM.                                                    "fldcat1
    *&      Form  build_layout
          text
    FORM BUILD_LAYOUT .
      LAYOUT-NO_INPUT          = 'X'.
      LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
      LAYOUT-ZEBRA = 'X'.
      LAYOUT-TOTALS_TEXT       = 'Totals'(256).
    layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.                   
    But when I run this query,the program gets terminated.Can you please help me in rectifying the query and generate the output?
    Thanks in advance
    Bhavin

    Hi
    I have corrected the code please copy and past it and then try.
    Report ZT_SERIAL.
    TABLES : SER01,SER03,OBJK,LIKP,LIPS.
    " LIKP - SD invoice header table, LIPS - SD invoice details table
    TYPE-POOLS: SLIS.
    DATA: AFIELD TYPE SLIS_FIELDCAT_ALV.
    DATA: FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
         + MANDATORY WHILE DECLARING ALV ***
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV..
    DATA: V_EVENTS TYPE SLIS_T_EVENT.
    DATA: LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: I_TITLE_SL_NO_TRACK TYPE LVC_TITLE VALUE 'SERIAL NO TRACKER'.
    DATA : BEGIN OF ITAB OCCURS 0,
    OBKNR LIKE OBJK-OBKNR, "OBJECT LIST
    OBZAE LIKE OBJK-OBZAE, "OBJECT COUNTER
    KUNDE LIKE SER01-KUNDE, "CUSTOMER NO
    MATNR LIKE OBJK-MATNR, "PART NO
    SERNR LIKE OBJK-SERNR, "SERIAL NO
    MBLNR LIKE SER03-MBLNR, "GRN/MATERIAL DOC NO
    LIEF_NR LIKE SER01-LIEF_NR,"OUTBOUND DELV NO
    DATUM LIKE SER01-DATUM, "OUTBOUND DELV DATE
    TASER LIKE OBJK-TASER, "HEADER TABLE
    ANZSN LIKE SER01-ANZSN, "NO OF SERIAL NOS
    VGBEL LIKE LIPS-VGBEL, "SALES ORDER NO
    END OF ITAB.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_KUNDE FOR SER01-KUNDE,
    S_VGBEL FOR LIPS-VGBEL,
    S_MATNR FOR OBJK-MATNR,
    S_SERNR FOR OBJK-SERNR,
    S_MBLNR FOR SER03-MBLNR,
    S_LIFNR FOR SER01-LIEF_NR,
    S_DATUM FOR SER01-DATUM.
    SELECTION-SCREEN : END OF BLOCK B1.
    PERFORM TRACKING.
    PERFORM FLDCAT.
    PERFORM BUILD_LAYOUT.
    ***CALL FUNCTION TO DISPLAY IN ALV FORMAT*******
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    I_GRID_TITLE = I_TITLE_SL_NO_TRACK
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = P_FIELDTAB[]
    I_SAVE = 'A'
    IT_EVENTS = V_EVENTS
    TABLES
    T_OUTTAB = ITAB.
    ***END OF CALL FUNCTION
    FORM TRACKING.
    *SELECT OBJK~OBKNR
          OBJK~OBZAE
          OBJK~MATNR
          OBJK~SERNR
          OBJK~TASER
          SER01~KUNDE
          SER01~LIEF_NR
          SER01~DATUM
          SER01~ANZSN
          SER03~MBLNR
          LIPS~VGBEL
      INTO TABLE ITAB FROM OBJK
      INNER JOIN  SER01 ON OBJKOBKNR = SER01OBKNR
      INNER JOIN  SER03 ON OBJKOBKNR = SER03OBKNR
      INNER JOIN  LIPS ON SER01LIEF_NR = LIPSVBELN
      WHERE
    *( OBJKTASER = 'SER01' OR OBJKTASER = 'SER03' ) and
    *OBJK-MATNR IN S_MATNR AND
    *OBJK~SERNR IN S_SERNR AND
    *SER01~KUNDE IN S_KUNDE AND
    *SER01~LIEF_NR IN S_LIFNR AND
    *SER01~DATUM IN S_DATUM AND
    *SER03~MBLNR IN S_MBLNR AND
    *LIPS~VGBEL IN S_VGBEL.
    SELECT a~OBKNR         "OBJK
           a~OBZAE
           a~MATNR
           a~SERNR
           a~TASER
           b~KUNDE         "SER01
           b~LIEF_NR
           b~DATUM
           b~ANZSN
           c~MBLNR        "SER03
           D~VGBEL        "LIPS
       INTO TABLE ITAB FROM  ( OBJK as a
       INNER JOIN  SER01 as b ON aOBKNR = bOBKNR
       INNER JOIN  SER03 as c ON aOBKNR = cOBKNR
       INNER JOIN  LIPS as  d ON bLIEF_NR = dVBELN )
       WHERE
    ( aTASER = 'SER01' OR aTASER = 'SER03' ) and
    a~MATNR IN S_MATNR AND
    a~SERNR IN S_SERNR AND
    b~KUNDE IN S_KUNDE AND
    b~LIEF_NR IN S_LIFNR AND
    b~DATUM IN S_DATUM AND
    c~MBLNR IN S_MBLNR AND
    d~VGBEL IN S_VGBEL.
    ENDFORM.
    *& Form fldcat
       * text
    FORM FLDCAT.
    PERFORM FLDCAT1 USING 'KUNDE' 'Customer No'.
    PERFORM FLDCAT1 USING 'VGBEL' 'Sales Order No'.
    PERFORM FLDCAT1 USING 'MATNR' 'Tejas Part No'.
    PERFORM FLDCAT1 USING 'SERNR' 'Serial No'.
    PERFORM FLDCAT1 USING 'MBLNR' 'Material Doc No'.
    PERFORM FLDCAT1 USING 'LIEF_NR' 'Outbound Delv No'.
    PERFORM FLDCAT1 USING 'DATUM' 'Outbound Delv Date'.
    ENDFORM. "fldcat
    *& Form fldcat1
        text
        -->FNAM text
        -->FTEXT text
    FORM FLDCAT1 USING FNAM FTEXT.
    DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    L_FIELDCAT-FIELDNAME = FNAM.
    L_FIELDCAT-SELTEXT_M = FTEXT.
    IF FNAM EQ 'MATNR'."OR fnam EQ 'PKUNAG'.
    L_FIELDCAT-KEY = 'X'.
    ENDIF.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    APPEND L_FIELDCAT TO P_FIELDTAB.
       * CLEAR fldcat1.
    ENDFORM. "fldcat1
    *& Form build_layout
       * text
    FORM BUILD_LAYOUT .
    LAYOUT-NO_INPUT = 'X'.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-TOTALS_TEXT = 'Totals'(256).
       * layout-coltab_fieldname = 'CELL_COLOUR'.
    *clear layout.
    ENDFORM.
    Regards,
    Venkat

Maybe you are looking for

  • [SOLVED] Run xscreensaver when I close the laptop lid

    I have xscreensaver running in my archlinux, and with a systemd service, I can start it after waking up my laptop. The problem is that I like to keep my laptop running when I close the lid (for example, to go to bed while I'm downloading a file, I li

  • Home from College

    For college, I bought a new imac G5. My parents followed suit and replaced their old mac. At my dorm, I was obviously hooked up to the internet through the school, however, I am now home and i do not have the internet on my computer. My parent's comp

  • Error MEPO000

    Hi friends , When i am saving the PO , the system showing error message " Purchase order still contains faulty items Message no. MEPO000" , so what should be the problem . When give tax code in invoice tab then only it appear . Please reply , Raghu

  • 2008 R2 failover cluster dns

    Hello, Wondering if there is any best practices when it comes to setting up DNS. Options are either dynamic DNS or add static A records for nodes and cluster name. Also I understand that there will be no DNS servers specified in TCP properties of the

  • Whitelist Removal

    My company email is being blocked by Verizon. I've submitted numerous whitelist removal requests but nothing has changed.