What is syntax for inner join of Select statement with  Secondary Index

Hi Genies,
                Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
             INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
             WHERE A~OBJNR = OBJNR
             AND A~GJAHR = CURRY
             AND B~GJAHR = CURRY
             AND A~RBEST = ''
             AND A~BEKNZ = 'S'
             AND B~BELNR NE WA_COBK-BELNR
             AND B~AWREF_REV = ''
             AND B~AWORG_REV = ''
             AND B~KOKRS = WA_COIOB-KOKRS
             AND B~BLDAT BETWEEN START_DATE AND END_DATE
             AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
index name is ZBU.
please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
Regards,
        Thangam.P

Hi Genies,
                Here i have created the Secondary index for table COEP and also used for select query but there is no improvement in runtime . taking same time for select query without index as well as with index. my code is
SELECT *  INTO CORRESPONDING FIELDS OF TABLE ITAB_COEP FROM COEP AS A
             INNER JOIN COBK  AS B ON ( A~BELNR = B~BELNR AND A~KOKRS = B~KOKRS AND A~GJAHR = B~GJAHR )
             WHERE A~OBJNR = OBJNR
             AND A~GJAHR = CURRY
             AND B~GJAHR = CURRY
             AND A~RBEST = ''
             AND A~BEKNZ = 'S'
             AND B~BELNR NE WA_COBK-BELNR
             AND B~AWREF_REV = ''
             AND B~AWORG_REV = ''
             AND B~KOKRS = WA_COIOB-KOKRS
             AND B~BLDAT BETWEEN START_DATE AND END_DATE
             AND B~BLART IN ('SA','KA','KR','AB')  %_HINTS ORACLE 'INDEX("COEP" "COEP~ZBU")'.
index name is ZBU.
please any one let me know is there any syntax mistakes? but while checking and during the runtime it does'nt shows any error.
Regards,
        Thangam.P

Similar Messages

  • Join a SELECT-Statement with a INDEX

    can I force a SELECT-Statement to use a certain Table-INDEX?
    f.e.
    select * from table a
    where a.key like '%p'
    ..forced index a.idx.--

    Yes. You can.
    Use SQL hint.
    select /*+ index (tablename indexname) */.
    If the index is usable-Oracle will use it. If not -Oracle will see it as a remark.

  • Time taking for inner joins in select

    Hi all,
    I am using inner join on 3 tables  ( PLKO,PLPO,PLAS) for the materials,
    it is taking database time 20% and abap time 78 %  and when i am using FM CARO_ROUTING_READ
    database time 48% and abap 52%.
    i am in confusion which is th ebest method to use inner join or FM.
    when i am checking in the server for plant in the selection screen , it is running lot of time
    This is first time i am working on the performance issue.
    Can you please anbody help me how to solve this issue.
    Regards,
    Madhavi

    Percentages don't mean much, how does the overall runtime compare? Is there a problem at all?
    Since you already used SE30, go a step further and study the hit list sorted by net time descending, only look at the top few items.
    Also read this:
    Please Read before Posting in the Performance and Tuning Forum
    Thomas

  • Inner join in select statement

    hi,
    i am using select statement like
    SELECT ekkoebeln ekkobukrs ekkobstyp ekkobsart ekko~ernam
               ekkolifnr ekkozterm ekkozbd1t ekkozbd2t ekko~zbd3t
               ekkozbd1p ekkozbd2p ekkoekorg ekkoekgrp ekko~waers
               ekkowkurs ekkokufix ekkobedat ekkokdate
    Begin of Changes, RICEF : 293.
               ekkozzhedg ekkozzheda ekkozzpba ekkozzpbubu lfa1~vbund
    End of Changes, RICEF . 293.
             lfa1land1 lfa1name1
             ekpa~lifn2
             INTO CORRESPONDING FIELDS OF TABLE iekko
             FROM ekko
                  JOIN lfa1 ON lfa1lifnr = ekkolifnr
                  LEFT JOIN ekpa ON ekpaebeln = ekkoebeln AND
                                    ekpa~ebelp = '00000'    AND
                                    ekpa~parvw = 'RS'
             FOR ALL entries IN icooi
             WHERE ekko~ebeln = icooi-refbn
             AND   ekko~zzhedg IN s_zzhedg
             AND   ekko~zzheda IN s_zzheda.
    where in ekko table ,the fields zzhedg and zzheda are appended..but in the debugging mode i am unable to see this 2 field....in the output also....so how should i write my select query?

    Hi,
    Is your select statement returning sy-subrc 0. In debugging mode may be your fields may not be visible in the screen since your internal table has many fields, you have to press >> forward button to check the fields.
    Thanks & Regards,
    Navneeth K.

  • Select query with secondary index

    hi,
    i have a report which is giving performance issues on a perticular select query on KONH table.
    the select query doesnt use the primary key fields and table already has around 19 million entries.So there was a secondary index created for the fields in the table.
    now, KONH is a client specific table, and hence has MANDT as the first field. when the table is not indexed it is sorted according to the order of fields, like first MANDT, then primary key fields and then remaining fields.. (correct me if i am wrong)
    but the secondary index created doesnt has MANDT in it..(yea, a mistake! )...
    but instead of correccting the secondary index, i am told to change the select query..
    so, i used a "client specific" syntax to sort the issue.. but i dont understand whre i should put the "where mandt eq sy-mandt" clause..
    should i put it right after all my secondary index fields are over? or what happens to the order of fields which are not present in the list of secondary index?
    kindaly help.
    thanx.

    Hi chinmay kulkarni,
    its better if you can ask concerned person to add MANDT field in your  index as well....
    Indexes and MANDT
    If a table begins with the mandt field, so should its indexes. If a table begins with mandt and an index doesn't, the optimizer might not use the index.
    Remember, if you will, Open SQL's automatic client handling feature. When select * from ztxlfa1 where land1 = 'US' is executed, the actual SQL sent to the database is select * from ztxlfa1 where mandt = sy-mandt and land1 = 'US'. Sy-mandt contains the current logon client. When you select rows from a table using Open SQL, the system automatically adds sy-mandt to the where clause, which causes only those rows pertaining to the current logon client to be found.
    When you create an index on a table containing mandt, therefore, you should also include mandt in the index. It should come first in the index, because it will always appear first in the generated SQL.
    Index: Technical key of a database table.
    Primary index: The primary index contains the key fields of the table and a pointer to the non-key fields of the table. The primary index is created automatically when the table is created in the database.
    Secondary index: Additional indexes could be created considering the most frequently accessed dimensions of the table.
    Structure of an Index
    An index can be used to speed up the selection of data records from a table.
    An index can be considered to be a copy of a database table reduced to certain fields. The data is stored in sorted form in this copy. This sorting permits fast access to the records of the table (for example using a binary search). Not all of the fields of the table are contained in the index. The index also contains a pointer from the index entry to the corresponding table entry to permit all the field contents to be read.
    When creating indexes, please note that:
    An index can only be used up to the last specified field in the selection! The fields which are specified in the WHERE clause for a large number of selections should be in the first position.
    Only those fields whose values significantly restrict the amount of data are meaningful in an index.
    When you change a data record of a table, you must adjust the index sorting. Tables whose contents are frequently changed therefore should not have too many indexes.
    Make sure that the indexes on a table are as disjunctive as possible.
    (That is they should contain as few fields in common as possible. If two indexes on a table have a large number of common fields, this could make it more difficult for the optimizer to choose the most selective index.)
    For Example...
    SELECT KUNNR KUNN2 INTO TABLE T_CUST_TERR
    FROM KNVP CLIENT SPECIFIED
    WHERE MANDT = SY-MANDT " here MANDT shd be first
    AND KUNN2 IN S_TERR
    AND PARVW LIKE 'Z%'.
    Accessing tables using Indexes
    The database optimizer decides which index on the table should be used by the database to access data records.
    You must distinguish between the primary index and secondary indexes of a table. The primary index contains the key fields of the table. The primary index is automatically created in the database when the table is activated. If a large table is frequently accessed such that it is not possible to apply primary index sorting, you should create secondary indexes for the table.
    The indexes on a table have a three-character index ID. '0' is reserved for the primary index. Customers can create their own indexes on SAP tables; their IDs must begin with Y or Z.
    If the index fields have key function, i.e. they already uniquely identify each record of the table, an index can be called a unique index. This ensures that there are no duplicate index fields in the database.
    When you define a secondary index in the ABAP Dictionary, you can specify whether it should be created on the database when it is activated. Some indexes only result in a gain in performance for certain database systems. You can therefore specify a list of database systems when you define an index. The index is then only created on the specified database systems when activated
    Also pls have a look on below link
    http://www.sapfans.com/sapfans/forum/devel/messages/30240.html
    Hope it will solve your problem..
    Reward points if useful...
    Thanks & Regards
    ilesh 24x7

  • Inner join and select for all entries with respect to performance

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient? and how? can you explain me in detail ?
    Regards,
    Dinesh

    INNER JOIN->
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21ec77446011d189700000e8322d00/content.htm
    FOR ALL ENTRIES->
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.

  • Inner join and select for all entries with respect to performance in SAP

    Hi Friends,
    I just want to know which is more efficient with respect to performance the Inner join or select for all entries?which is more efficient?
    Regards,
    Dinesh

    I did some testing a while ago and found that a JOIN is usually a bit more efficient than FOR ALL ENTRIES. This wasn't always the case though, so the best thing to do is to write it both ways and see which is faster.
    Rob

  • Syntax of  inner join

    hello sir,
                 plz tell me the syntax of inner join for three tables.

    Syntax
    ... [(] {dbtab_left [AS tabalias_left]} | join
    {[INNER] JOIN}|{LEFT [OUTER] JOIN}
    {dbtab_right [AS tabalias_right] ON join_cond} [)] ... .
    Effect
    The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
    On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
    AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
    The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
    At least one comparison must be specified after ON.
    Individual comparisons may be joined using AND only.
    All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
    The following language elements may not be used: BETWEEN, LIKE, IN.
    No sub-queries may be used.
    For outer joins, only equality comparisons (=, EQ) are possible.
    If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
    In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
    Resulting set for inner join
    The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
    Resulting set for outer join
    The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
    Example
    Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
    PARAMETERS: p_cityfr TYPE spfli-cityfrom,
    p_cityto TYPE spfli-cityto.
    DATA: BEGIN OF wa,
    fldate TYPE sflight-fldate,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa.
    DATA itab LIKE SORTED TABLE OF wa
    WITH UNIQUE KEY fldate carrname connid.
    SELECT ccarrname pconnid f~fldate
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM ( ( scarr AS c
    INNER JOIN spfli AS p ON pcarrid = ccarrid
    AND p~cityfrom = p_cityfr
    AND p~cityto = p_cityto )
    INNER JOIN sflight AS f ON fcarrid = pcarrid
    AND fconnid = pconnid ).
    LOOP AT itab INTO wa.
    WRITE: / wa-fldate, wa-carrname, wa-connid.
    ENDLOOP.
    Example
    Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
    PARAMETERS p_cityfr TYPE spfli-cityfrom.
    DATA: BEGIN OF wa,
    carrid TYPE scarr-carrid,
    carrname TYPE scarr-carrname,
    connid TYPE spfli-connid,
    END OF wa,
    itab LIKE SORTED TABLE OF wa
    WITH NON-UNIQUE KEY carrid.
    SELECT scarrid scarrname p~connid
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM scarr AS s
    LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
    AND p~cityfrom = p_cityfr.
    LOOP AT itab INTO wa.
    IF wa-connid = '0000'.
    WRITE: / wa-carrid, wa-carrname.
    ENDIF.
    ENDLOOP.
    we r using 2 type of joins in abap they are
    1) inner join.
    this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after innerjoining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    1 2 3 5
    only common field is taken..
    2)left outer join
    here it wil work in opossite way it will give values whic are not common
    itab1 itab2
    a b c a d
    1 2 3 1 5
    2 3 4 3 6
    after left outer joining itab1 n itab2 on field a we wil get the o/p as
    a b c d
    2 3 4
    only fields which are not common is taken from the left table..other field(d here) wil be empty
    I think it will help u.
    Reward Points if helpful.
    Check for ALVROBOT.COM also it is also helpful.

  • Need help with program for Inner join

    Hello Experts,
    I need to create a list from table sbook containing booking number (sbook-bookid), customer number (sbook-customid), customer name (scustom-name) , customer class (sbook-class) and ticket price (sflight-price). I am new to ABAP and am very confused I tried reading up some examples and came up with the attached program
    Attached is my program for inner join
    Kindly Help
    Thanks Su

    Hi Su K
              You May use key fields , Foreign keys for joining , Here
    SELECT SBOOK~BOOKID SBOOK~CUSTOMID SBOOK~CLASS
      SCUSTOM~ID SCUSTOM~NAME  FROM SFILGHT
       INNER JOIN SBOOK ON   SBOOK~CARRID EQ SFILGHT~CARRID
                                              SBOOK~CONNID EQ SFILGHT~CONNID
                                              SBOOK~FLDATE EQ SFILGHT~FLDATE
      INNER JOIN SCUSTOM ON SCUSTOM~ID = SBOOK~ID

  • Alternate for inner join to improve performance

    Hi all,
    I have used an inner join query to fetch data from five different tables into an internal table with where clause conditions.
    The execution time is almost 5-6 min for this particular query(I have more data in all five DB tables- more than 10 million records in every table).
    Is there any alternate for inner join to improve performance.?
    TIA.
    Regards,
    Karthik

    Hi All,
    Thanks for all your interest.
    SELECT  a~object_id a~description a~descr_language
                a~guid AS object_guid a~process_type
                a~changed_at
                a~created_at AS created_timestamp
                a~zzorderadm_h0207 AS cpid
                a~zzorderadm_h0208 AS submitter
                a~zzorderadm_h0303 AS cust_ref
                a~zzorderadm_h1001 AS summary
                a~zzorderadm_h1005 AS summary_uc
                a~zzclose_date     AS clsd_date
                d~stat AS status
                f~priority
                FROM crmd_orderadm_h AS a INNER JOIN crmd_link AS b ON  a~guid = b~guid_hi
                INNER JOIN crmd_partner AS c ON b~guid_set = c~guid
                INNER JOIN crm_jest AS d ON objnr  = a~guid
                INNER JOIN crmd_activity_h AS f ON f~guid = a~guid
                INTO CORRESPONDING FIELDS OF TABLE et_service_request_list
                WHERE process_type IN lt_processtyperange
                AND   a~created_at IN lt_daterange
                AND   partner_no IN lr_partner_no
                AND   stat IN lt_statusrange
                AND   object_id IN lt_requestnumberrange
                AND   zzorderadm_h0207 IN r_cpid
                AND   zzorderadm_h0208 IN r_submitter
                AND   zzorderadm_h0303 IN r_cust_ref
                AND   zzorderadm_h1005 IN r_trans_desc
                AND   d~inact = ' '
                AND   b~objtype_hi = '05'
                AND   b~objtype_set = '07'.
                f~priority
                FROM crmd_orderadm_h AS a INNER JOIN crmd_link AS b ON  a~guid = b~guid_hi
                INNER JOIN crmd_partner AS c ON b~guid_set = c~guid
                INNER JOIN crm_jest AS d ON objnr  = a~guid
                INNER JOIN crmd_activity_h AS f ON f~guid = a~guid
                INTO CORRESPONDING FIELDS OF TABLE et_service_request_list
                WHERE process_type IN lt_processtyperange
                AND   a~created_at IN lt_daterange
                AND   partner_no IN lr_partner_no
                AND   stat IN lt_statusrange
                AND   object_id IN lt_requestnumberrange
                AND   zzorderadm_h0207 IN r_cpid
                AND   zzorderadm_h0208 IN r_submitter
                AND   zzorderadm_h0303 IN r_cust_ref
                AND   zzorderadm_h1005 IN r_trans_desc
                AND   d~inact = ' '
                AND   b~objtype_hi = '05'
                AND   b~objtype_set = '07'.

  • Joins And For all Enteries in Select Statement

    Could you please tell me when there is a high amount of data which is being handled in the table, does the use of INNER JOINS and FOR ALL ENTERIES in SELECT Statement decreases the system performance? ?
    Can you also let me know where can i get some tips regarding do's and dont's for ABAP Programming, I want to increase my system performance.
    Currently the programs which are being used are taking a lot of time for execution...
    Its very URGENT!

    Hai Jyotsna
    Go through the following Tips for improving Performence
    For all entries
    The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
    The plus
    Large amount of data
    Mixing processing and reading of data
    Fast internal reprocessing of data
    Fast
    The Minus
    Difficult to program/understand
    Memory could be critical (use FREE or PACKAGE size)
    Some steps that might make FOR ALL ENTRIES more efficient:
    Removing duplicates from the driver table
    Sorting the driver table
    If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
                   FOR ALL ENTRIES IN i_tab
                      WHERE mykey >= i_tab-low and
                 mykey <= i_tab-high.
    Nested selects
    The plus:
    Small amount of data
    Mixing processing and reading of data
    Easy to code - and understand
    The minus:
    Large amount of data
    when mixed processing isn’t needed
    Performance killer no. 1
    Select using JOINS
    The plus
    Very large amount of data
    Similar to Nested selects - when the accesses are planned by the programmer
    In some cases the fastest
    Not so memory critical
    The minus
    Very difficult to program/understand
    Mixing processing and reading of data not possible
    Use the selection criteria
    SELECT * FROM SBOOK.                   
      CHECK: SBOOK-CARRID = 'LH' AND       
                      SBOOK-CONNID = '0400'.        
    ENDSELECT.                             
    SELECT * FROM SBOOK                     
      WHERE CARRID = 'LH' AND               
            CONNID = '0400'.                
    ENDSELECT.                              
    Use the aggregated functions
    C4A = '000'.              
    SELECT * FROM T100        
      WHERE SPRSL = 'D' AND   
            ARBGB = '00'.     
      CHECK: T100-MSGNR > C4A.
      C4A = T100-MSGNR.       
    ENDSELECT.                
    SELECT MAX( MSGNR ) FROM T100 INTO C4A 
    WHERE SPRSL = 'D' AND                
           ARBGB = '00'.                  
    Select with view
    SELECT * FROM DD01L                    
      WHERE DOMNAME LIKE 'CHAR%'           
            AND AS4LOCAL = 'A'.            
      SELECT SINGLE * FROM DD01T           
        WHERE   DOMNAME    = DD01L-DOMNAME 
            AND AS4LOCAL   = 'A'           
            AND AS4VERS    = DD01L-AS4VERS 
            AND DDLANGUAGE = SY-LANGU.     
    ENDSELECT.                             
    SELECT * FROM DD01V                    
    WHERE DOMNAME LIKE 'CHAR%'           
           AND DDLANGUAGE = SY-LANGU.     
    ENDSELECT.                             
    Select with index support
    SELECT * FROM T100            
    WHERE     ARBGB = '00'      
           AND MSGNR = '999'.    
    ENDSELECT.                    
    SELECT * FROM T002.             
      SELECT * FROM T100            
        WHERE     SPRSL = T002-SPRAS
              AND ARBGB = '00'      
              AND MSGNR = '999'.    
      ENDSELECT.                    
    ENDSELECT.                      
    Select … Into table
    REFRESH X006.                 
    SELECT * FROM T006 INTO X006. 
      APPEND X006.                
    ENDSELECT
    SELECT * FROM T006 INTO TABLE X006.
    Select with selection list
    SELECT * FROM DD01L              
      WHERE DOMNAME LIKE 'CHAR%'     
            AND AS4LOCAL = 'A'.      
    ENDSELECT
    SELECT DOMNAME FROM DD01L    
    INTO DD01L-DOMNAME         
    WHERE DOMNAME LIKE 'CHAR%' 
           AND AS4LOCAL = 'A'.  
    ENDSELECT
    Key access to multiple lines
    LOOP AT TAB.          
    CHECK TAB-K = KVAL. 
    ENDLOOP.              
    LOOP AT TAB WHERE K = KVAL.     
    ENDLOOP.                        
    Copying internal tables
    REFRESH TAB_DEST.              
    LOOP AT TAB_SRC INTO TAB_DEST. 
      APPEND TAB_DEST.             
    ENDLOOP.                       
    TAB_DEST[] = TAB_SRC[].
    Modifying a set of lines
    LOOP AT TAB.             
      IF TAB-FLAG IS INITIAL.
        TAB-FLAG = 'X'.      
      ENDIF.                 
      MODIFY TAB.            
    ENDLOOP.                 
    TAB-FLAG = 'X'.                  
    MODIFY TAB TRANSPORTING FLAG     
               WHERE FLAG IS INITIAL.
    Deleting a sequence of lines
    DO 101 TIMES.               
      DELETE TAB_DEST INDEX 450.
    ENDDO.                      
    DELETE TAB_DEST FROM 450 TO 550.
    Linear search vs. binary
    READ TABLE TAB WITH KEY K = 'X'.
    READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
    Comparison of internal tables
    DESCRIBE TABLE: TAB1 LINES L1,      
                    TAB2 LINES L2.      
    IF L1 <> L2.                        
      TAB_DIFFERENT = 'X'.              
    ELSE.                               
      TAB_DIFFERENT = SPACE.            
    LOOP
    AT TAB1.                     
        READ TABLE TAB2 INDEX SY-TABIX. 
        IF TAB1 <> TAB2.                
          TAB_DIFFERENT = 'X'. EXIT.    
        ENDIF.                          
      ENDLOOP.                          
    ENDIF.                              
    IF TAB_DIFFERENT = SPACE.           
    ENDIF.                              
    IF TAB1[] = TAB2[].  
    ENDIF.               
    Modify selected components
    LOOP AT TAB.           
    TAB-DATE = SY-DATUM. 
    MODIFY TAB.          
    ENDLOOP.               
    WA-DATE = SY-DATUM.                    
    LOOP AT TAB.                           
    MODIFY TAB FROM WA TRANSPORTING DATE.
    ENDLOOP.                               
    Appending two internal tables
    LOOP AT TAB_SRC.              
      APPEND TAB_SRC TO TAB_DEST. 
    ENDLOOP
    APPEND LINES OF TAB_SRC TO TAB_DEST.
    Deleting a set of lines
    LOOP AT TAB_DEST WHERE K = KVAL. 
      DELETE TAB_DEST.               
    ENDLOOP
    DELETE TAB_DEST WHERE K = KVAL.
    Tools available in SAP to pin-point a performance problem
    ·                The runtime analysis (SE30)
    ·                SQL Trace (ST05)
    ·                Tips and Tricks tool
    ·                The performance database
    Optimizing the load of the database
    Using table buffering
    Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:
    Select DISTINCT
    ORDER BY / GROUP BY / HAVING clause
    Any WHERE clause that contains a sub query or IS NULL expression
    JOIN s
    A SELECT... FOR UPDATE
    If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause.
    Use the ABAP SORT Clause Instead of ORDER BY
    The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.
    If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.
    Avoid the SELECT DISTINCT Statement
    As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
    Thanks & regards
    Sreenivasulu P

  • Oj syntax for outer join

    Is there a way to make Crystal Reports XI not generate the {oj .....   syntax for outer joins?
    In Crystal Reports 8, you could do a registry change to keep CR from using oj, but that doesn't seem to work on CR XI (or I don't know where to make the registry change)

A: oj syntax for outer join

Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"

Outer Join Escape Sequence builds the syntax for ODBC drivers using the outer join syntax in its SQL syntax.
Use Regedit on the problem client machine add following keys:
STEP 1........For Crystal Reports 9: HKEY_CURRENT_USER\Software\Crystal Decisions\9.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
<<<OR>>>
...................For Crystal Reports 10:HKEY_CURRENT_USER\Software\Crystal Decisions\10.0\Crystal Reports\Database\QueryBuilder\OuterJoinEscSeq
STEP 2........"MSOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that support Microsoft ODBC {oj ..} join escape sequence.
"NoOuterJoinEscSeq"= "insert your ODBC driver name here": List of the drivers that do not support any join escape sequence.
For example...
MSOuterJoinEscSeq = "UVODBC"

  • How to use bind variable value for table name in select statement.

    Hi everyone,
    I am having tough time to use value of bind variable for table name in select statement. I tried &p37_table_name. ,
    :p37_table_name or v('p37_table_name) but none worked.
    Following is the sql for interactive report:
    select * from v('p37_table_name') where key_loc = :P37_KEY_LOC and
    to_char(inspection_dte,'mm/dd/yyyy') = :P37_INSP_DT AND :p37_column_name is not null ;
    I am setting value of p37_table_name in previous page which is atm_state_day_insp.
    Following is error msg:
    "Query cannot be parsed, please check the syntax of your query. (ORA-00933: SQL command not properly ended) "
    Any help would be higly appreciated.
    Raj

    Interestingly enough I always had the same impression that you had to use a function to do this but found out from someone else that all you need to do is change the radio button from Use Query-Specific Column Names and Validate Query to Use Generic Column Names (parse query at runtime only). Apex will substitute your bind variable for you at run-time (something you can't normally do in pl/sql without using dynamic sql)

  • How to compile the hint to force selection statement to use index

    Hello expert,
    will you please tell me how to compile the hint to force selection statement to use index?
    Many Thanks,

    Not sure what you mean by compile, but hint is enclosed in /*+ hint */. Index hint is INDEX(table_name,index_name). For example:
    SQL> explain plan for
      2  select * from emp
      3  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    14 |   546 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS FULL| EMP  |    14 |   546 |     3   (0)| 00:00:01 |
    8 rows selected.
    SQL> explain plan for
      2  select /*+ index(emp,pk_emp) */ *
      3  from emp
      4  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 4170700152
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |    14 |   546 |     2   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |    14 |   546 |     2   (0)| 00:00:01 |
    |   2 |   INDEX FULL SCAN           | PK_EMP |    14 |       |     1   (0)| 00:00:01 |
    9 rows selected.
    SQL> Hint in the above example is forcing optimizer to use index which resul;ts in a bad execution plan. Most of the time optimizer does not need hints and chooses an optimal plan. In most cases sub-optimal plan is result of stale or incomplete statistics.
    SY.

  • How to avoid data repetation when using select statements with innerjoin

    how to avoid data repetation when using select statements with innerjoin.
    thanks in advance,
    satheesh

    you can use a query like this...
      SELECT DISTINCT
             frg~prc_group1                  "Product Group 1
             frg~prc_group2                  "Product Group 2
             frg~prc_group3                  "Product Group 3
             frg~prc_group4                  "Product Group 4
             frg~prc_group5                  "Product Group 5
             prc~product_id                  "Product ID
             txt~short_text                  "Product Description
    UP TO 10 ROWS
    INTO TABLE l_i_data
    FROM
    Joining CRMM_PR_SALESG and
    COMM_PR_FRG_ROD
    crmm_pr_salesg AS frg
    INNER JOIN comm_pr_frg_rod AS prd
    ON frgfrg_guid = prdfragment_guid
    Joining COMM_PRODUCT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_product AS prc
    ON prdproduct_guid = prcproduct_guid
    Joining COMM_PRSHTEXT and
    COMM_PR_FRG_ROD
    INNER JOIN comm_prshtext AS txt
    ON prdproduct_guid = txtproduct_guid
    WHERE frg~prc_group1 IN r_zprc_group1
       AND frg~prc_group2 IN r_zprc_group2
       AND frg~prc_group3 IN r_zprc_group3
       AND frg~prc_group4 IN r_zprc_group4
       AND frg~prc_group5 IN r_zprc_group5.
    reward it it helps
    Edited by: Apan Kumar Motilal on Jun 24, 2008 1:57 PM

  • Maybe you are looking for