'FOR ALL ENTRIES' in SELECT statements

Hi,
I got a doubt in working of the 'FOR ALL ENTRIES' option in the SELECT statement. Here is my scenarion.
Table A - Document Header Level (Key: Doc Number)
Internal Table B - Document Item level (Keys: Doc num and Doc Item).
So, for each record in Table A, table B will have multiple records.
In this situation, how the below SELECT will work.
SELECT <field names> INTO <some internal table>
                     FROM A
                     FOR ALL ENTRIES in B
                     WHERE doc_num = B-doc_num.
Will the above SELECT result in duplicate records or not?
(I tested it and found that it doesn't! I was lil surprised and wanted to confirm that)
Thanks & Regards,
Sree

Hi,
For all entries option basically sorts out the entries in the internal tbale based on the where condition and thus it only picks the unique entries based on the list.
so indeed your table A is a header one so it will give you only single value. if you go by the reverse way where in look for B for all entries in A it will give you multiple values as table B has multiple values for each value in A.
Regards,
Jagath

Similar Messages

  • What is the use of for all entries in select statement

    what is the use of for all entries in select statement

    hi,
    FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
    You can check the below code -
    SELECT BUKRS BELNR GJAHR AUGDT
    FROM BSEG
    INTO TABLE I_BSEG
    WHERE BUKRS = ....
    SELECT BUKRS BELNR BLART BLDAT
    FROM BKPF
    INTO TABLE I_BKPF
    FOR ALL ENTRIES IN I_BSEG
    WHERE BUKRS = I_BSEG-BUKRS
    AND BELNR = I_BSEG-BELNR
    AND BLDAT IN SO_BLDAT.
    *******************************8
    look another example
    what is the use of FOR ALL ENTRIES
    1. INNER JOIN
    DBTAB1 <----
    > DBTAB2
    It is used to JOIN two DATABASE tables
    having some COMMON fields.
    2. Whereas
    For All Entries,
    DBTAB1 <----
    > ITAB1
    is not at all related to two DATABASE tables.
    It is related to INTERNAL table.
    3. If we want to fetch data
    from some DBTABLE1
    but we want to fetch
    for only some records
    which are contained in some internal table,
    then we use for alll entries.
    1. simple example of for all entries.
    2. NOTE THAT
    In for all entries,
    it is NOT necessary to use TWO DBTABLES.
    (as against JOIN)
    3. use this program (just copy paste)
    it will fetch data
    from T001
    FOR ONLY TWO COMPANIES (as mentioned in itab)
    4
    REPORT abc.
    DATA : BEGIN OF itab OCCURS 0,
    bukrs LIKE t001-bukrs,
    END OF itab.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    itab-bukrs = '1000'.
    APPEND itab.
    itab-bukrs = '1100'.
    APPEND itab.
    SELECT * FROM t001
    INTO TABLE t001
    FOR ALL ENTRIES IN itab
    WHERE bukrs = itab-bukrs.
    LOOP AT t001.
    WRITE :/ t001-bukrs.
    ENDLOOP.
    Hope this helps!
    Regards,
    Anver
    <i>if hlped pls mark points</i>

  • Duplicate entries missing using for all entries in select query.

    Hi Gurus,
    Is there any way to avoid missing duplicate entries in an internal table if you use for all entries in select statement?
    Note : i am selecting two tables using non key fields and i have to aggregate the data. I want only 2 data fields and one amount field in my final internal table. I can add all the primary key fields into my internal table and collect my required fields in another table, but  I just want to know is there any other way to avoid missing duplicate entries without adding all the key fields?
    Regards,
    Raghavendra

    Hi,
    Just check what are the other possible fields in the table which may be having
    duplicate entries and make use of them in the selection accordingly.
    You may not miss any entries unless there is any restriction on them.
    You can better judge that in debugging mode while selecting data from that table.

  • 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

  • For all entries in select query

    Hi Guys,
    I am fetching the BUKRS GJAHR BELNR and BUZEI from BSEG table, using for all entires of BSEG data, i am getting the data from BSID table.
    But in BSID table, i have duplicate records, those records i am not able to get.
    Could you please suggest me, is any wrong in my code. Please sugest is any other way to get the data.
    SELECT bukrs
             belnr
             gjahr
             buzei
             xref1 INTO TABLE it_bseg
             FROM bseg
             WHERE bukrs = p_bukrs
              AND  gjahr IN s_gjahr
              AND  xref1 IN s_xref1.
      SORT it_bseg BY bukrs gjahr belnr buzei.
      SELECT bukrs
             kunnr
             zuonr
             gjahr
             belnr
             budat
             bldat
             xblnr
             blart
             dmbtr
             shkzg INTO TABLE it_bsid
             FROM bsid
             FOR ALL ENTRIES IN it_bseg
             WHERE bukrs = it_bseg-bukrs
               AND belnr = it_bseg-belnr
               AND gjahr = it_bseg-gjahr
               AND buzei = it_bseg-buzei
               AND blart IN r_blart.
    Thanks
    Gourisankar.

    Hi Sankar,
    if there are duplicates entries select statement will omit those records. try to include fields in the select statement which makes the selected record different from other atleast by one field.
    cheers!!

  • Usage of FOR ALL ENTRIES in SELECT query

    Hi All,
    While writing SELECT query using FOR ALL ENTRIES, in the WHERE condition can we use IN operator on a range table?
    Will this work out.
    Thanks,
    Anil Kumar

    HI,
    Yes you can use the in operator.
    SELECT *
      FROM MARC
      INTO TAB:E i_mARC
        FOR ALL ENTRIES IN I_MARA
      WHERE MATNR EQ I_MARA_MATNR
        AND WERKS IN S_WERKS.

  • Want to Avoid Loop for all entries with select query !!

    Hi Guru's  !
    This is my following code . I want to avoid loop  to improve the performance of program.
    data: lt_cuhd type HASHED TABLE OF /sapsll/cuhd WITH UNIQUE key guid_cuhd,
          ls_cuhd type /sapsll/cuhd.
    data: lt_comments type STANDARD TABLE OF zss_comments,
          ls_comments type zss_comments.
    data: lv_objkey type string.
    select * from /sapsll/cuhd into table lt_cuhd.
    loop at lt_cuhd  into ls_cuhd.
      CONCATENATE ls_cuhd-corder '%' into lv_objkey. " Example 'Mum%'
      select * from zss_comments into table lt_comments
                where objkey like lv_objkey
                 AND guid_cuhd = ls_cuhd-guid_cuhd
                  AND event_id <> ''.
    endloop.
    I want
    New code should be...using all entries no loop required.
      *select * from zss_comments into table lt_comments
                where objkey like lv_objkey
                 AND guid_cuhd = ls_cuhd-guid_cuhd
                  AND event_id <> ''.*

    why dont you add the object key also to  lt_cuhd and once you fetch the data to lt_cuhd loop it and add the '%'
    when looping use field symbols so that you dont have to use  modify.
    then use for all entries using lt_cuhd
    i don't you can find a better way to add the % mark apart from looping but by this way only one select query will be done for
    zss_comments
    Thanks
    Nafran

  • Problem with for all entries in select querry

    hi,
    Hi,
    I am using select queery like this
    SELECT  version  COUNT( * ) 
    from ztbi_default_va4
    INTO  CORRESPONDING FIELDS OF TABLE   lit_new 
    FOR ALL ENTRIES IN lit_new1
    WHERE network = lit_new1-network GROUP BY version.
    this is not working showing error as:
    The addition "FOR ALL ENTRIES" excludes all aggregate functions with          
    the exception of "COUNT( * )" as the single element of the SELECT     clause.     
    I am using only count(*) ,not using othes like max,min etc,,,,,,,,,
    please suggest any missing in syntax,,,,attach relavant code using count(*) with for all entreis
    any help appriciated,,,,,
    Thanks in advance,,,,

    Hi,
    Try this -
    TYPES: begin of t_data,
                 version TYPE version,
                 count    type i,
                 end of t_data.
    DATA: i_data TYPE STANDARD TABLE OF t_data,
               wa_data TYPE t_data.
    DATA: l_version TYPE version,
               l_count TYPE i.
    SELECT  version  COUNT( * ) 
    from ztbi_default_va4
    INTO  CORRESPONDING FIELDS OF TABLE   lit_new 
    FOR ALL ENTRIES IN lit_new1
    WHERE network = lit_new1-network.
    SORT lit_new.
    LOOP AT lit_new INTO lwa_new.
        IF lwa_new EQ l_version.
          l_count = l_count + 1.
        ELSE.
          wa_data-version = l_version.
          wa_data-count = l_count + 1.
          APPEND wa_data TO i_data.
          CLEAR: wa_data.
          CLEAR: l_count.
        ENDIF.
        l_version = lwa_new-version.
        CLEAR: lwa_new.
    I hope this will do.
    Make any necessary changes.
    Regards,
    Harsh Bansal

  • For all entries in read statement

    hi
    is there any command equivalent to for all entries in read statement

    Hi,
    You have to use Loop at...and move the values from the it_vbrp to the final internal table..
    Example
    LOOP AT IT_OUTPUT.
      MOVE-CORRESPONDING IT_OUTPUT TO IT_FINAL.
      LOOP AT IT_VBRP WHERE AUBEL = IT_OUTPUT-VBELN
                                    AND     AUPOS = IT_OUTPUT-POSNR.
          MOVE-CORRESPONDING IT_VBRP TO IT_FINAL.
          APPEND IT_FINAL.
      ENDLOOP.
      IF SY-SUBRC <> 0.
        APPEND IT_FINAL.
      ENDIF.
    ENDLOOP.
    Thanks,
    Naren

  • What is the usage of for all entries ?

    What is the Usage of read table  after using for all entries ?
    In the following example what exactly it is doing ?
      Usage of 'for all entries' in Select Statement
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      DATA: BEGIN OF T_VBAP OCCURS 0,
            VBELN  LIKE VBAP-VBELN,
            MATNR  LIKE VBAP-MATNR,
            POSNR  LIKE VBAP-POSNR,
            END OF T_VBAP.
      DATA: BEGIN OF T_VBFA OCCURS 0,
            VBELV  LIKE VBFA-VBELV,
            VBELN  LIKE VBFA-VBELN,
            VBTYP_N  LIKE VBFA-VBTYP_N,
            END OF T_VBFA.
      DATA: BEGIN OF T_VBAK OCCURS 0,
            VBELN  LIKE VBAK-VBELN,
            IHREZ  LIKE VBAK-IHREZ,
            END OF T_VBAK.
      DATA: BEGIN OF T_KNA1 OCCURS 0,
            KUNNR  LIKE KNA1-KUNNR,
            NAME1  LIKE KNA1-NAME1,
            END OF T_KNA1.
       DATA: BEGIN OF T_MAKT OCCURS 0,
            MATNR  LIKE MAKT-MATNR,
            MAKTX  LIKE MAKT-MAKTX,
            END OF T_MAKT.
      SELECT likpvbeln likplifex likpbldat likpwadat likpwadat_ist likpkodat likp~lfart
             likpkunnr likpvstel lipsposnv lipslfimg lipsvrkme lipslgmng lips~meins
             lipswerks lipslgort lipscharg lipsvbelv lipsposnr lipsmatnr
             lipsvbeln LIPSVGBEL LIPSVGPOS vbupkosta vbupwbsta vbupposnr vbup~vbeln
              VBAKIHREZ VBAKVBELN VBAP~VBELN
         INTO CORRESPONDING FIELDS OF TABLE  it_itab
        FROM ( likp
               INNER JOIN lips
               ON  lipsvbeln = likpvbeln
               INNER JOIN vbup
               ON  vbupposnr = lipsposnr
               and VBUPVBELN = LIPSVBELN )
              left outer join VBAK
              on  VBAKVBELN = LIPSVGBEL
              inner join VBAP
              on  VBAPVBELN = VBAKVBELN )
             WHERE likp~vbeln IN so_vbeln
               AND likp~lifex IN so_lifex
               AND likp~lfart IN so_lfart
               AND likp~kunnr IN so_kunnr
               AND likp~vstel IN so_vstel
               AND likp~bldat IN so_bldat
               AND likp~wadat_ist IN so_wadat
               AND vbup~kosta IN so_kosta
               AND vbup~wbsta IN so_wbsta
               AND LIPS~LFIMG NE 0.
      SELECT VBELN IHREZ INTO TABLE T_VBAK
      FROM VBAK
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELN = IT_ITAB-VGBEL.
    APPEND T_VBAK.
    ENDSELECT.
      SELECT VBELN MATNR POSNR INTO TABLE T_VBAP
      FROM VBAP
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELN = IT_ITAB-VGBEL AND
            MATNR = IT_ITAB-MATNR AND
            POSNR = IT_ITAB-VGPOS.
    APPEND T_VBAP.
    ENDSELECT.
      SELECT VBELV VBELN VBTYP_N INTO TABLE T_VBFA
      FROM VBFA
      FOR ALL ENTRIES IN  IT_ITAB
      WHERE VBELV = IT_ITAB-VBELN AND
            VBTYP_N = 'M' .
      SELECT KUNNR NAME1 INTO TABLE T_KNA1
      FROM KNA1
      FOR ALL ENTRIES IN IT_ITAB
      WHERE KUNNR = IT_ITAB-KUNNR.
    APPEND T_KNA1.
    ENDSELECT.
      SELECT MATNR MAKTX INTO TABLE T_MAKT
      FROM MAKT
      FOR ALL ENTRIES IN IT_ITAB
      WHERE MATNR = IT_ITAB-MATNR.
    APPEND T_MAKT.
    ENDSELECT.
    *Populate field with color attributes
      LOOP AT it_itab INTO wa_ITAB.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
    i.e. wa_ekko-line_color = 'C410'
        REFRESH color.
        colourize 'VBELN' 0. " .
        WA_ITAB-farbe = color[].
        ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
        IF ld_color = 3. "8
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ITAB-line_color.
        WA_ITAB-NAME1 = ''.
        WA_ITAB-MAKTX = ''.
        WA_ITAB-IHREZ = ''.
        WA_ITAB-VBELV = ''.
        READ TABLE T_KNA1 WITH KEY KUNNR = WA_ITAB-KUNNR.
        IF SY-SUBRC = 0.
           WA_ITAB-NAME1 = T_KNA1-NAME1.
        ENDIF.
        READ TABLE T_MAKT WITH KEY MATNR = WA_ITAB-MATNR.
        IF SY-SUBRC = 0.
        WA_ITAB-MAKTX = T_MAKT-MAKTX.
        ENDIF.
        READ TABLE T_VBAK WITH KEY VBELN = WA_ITAB-VGBEL.
        IF SY-SUBRC = 0.
        WA_ITAB-IHREZ = T_VBAK-IHREZ.
        ENDIF.
        READ TABLE T_VBFA WITH KEY VBELV = WA_ITAB-VBELN.
        IF SY-SUBRC = 0.
        WA_ITAB-VBELVA = T_VBFA-VBELN.
        ENDIF.
       READ TABLE T_VBAP WITH KEY VBELN = WA_ITAB-VGBEL
                                  POSNR = WA_ITAB-VGPOS
                                  MATNR = WA_ITAB-MATNR.
       IF SY-SUBRC = 0.
       WA_ITAB-IHREZ = T_VBAK-IHREZ.
       ENDIF.
    wa_ekko-line_color = 'C410'.
        MODIFY it_itab FROM wa_itab.
      ENDLOOP.
    ENDFORM. " data_retrieval

    hi Jyotirmoy,
    The explanation below can give u an idea of wat is going in ur code..
    Use of 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.
    Thankyou,
    Regards.

  • Select ....FOR ALL ENTRIES.... performance tuning

    I have the following SELECT statement:
    SELECT recn, recnroot, ippers
         INTO CORRESPONDING FIELDS OF TABLE <ITAB1>
       FROM CCIHT_IP
          FOR ALL ENTRIES IN <ITAB2>
    WHERE ippers = <ITAB2>-ippers
          AND valfr LE sy-datum
          AND valto GE sy-datum
          AND iptype = 'INJ'.
    Did a trace, and the SQL executed is:
    SELECT recn, recroot, ippers
       FROM CCIHT_IP
    WHERE mandt= ?
         AND ippers IN (?1, ..., ?10)
         AND valfr <= ?
         AND valto >= ?
         AND iptype = ?
         FOR FETCH ONLY WITH UR
    This is very slow.
    To speed it up, I programmatically break up the SQL using a range table:
    i.e.:   WHERE ...
                 AND IPPERS IN <RANGE TABLE>
        With the range table containing 1500 entries which is near the limit for IN statement. This is much faster.
    The question is why with the FOR ALL ENTRIES the IN statement contains only 10 values and not the maximum allowed, is this a database config issue ?

    Hi,
    as Thomas said for this case rsdb/max_in_blocking_factor is the parameter in question.
    And yes, Andrew, you are right, FAE parameters should not be changed system wide
    since the delivered default values are those values that turned out to be the best values
    in systemwide tests.
    However you can increase the value on statement level with a hint. So you can have both
    the FAE and a non default blocking for a specific statement.
    example:
    SELECT recn, recnroot, ippers
    INTO CORRESPONDING FIELDS OF TABLE <ITAB1>
    FROM CCIHT_IP
    FOR ALL ENTRIES IN <ITAB2>
    WHERE ippers = <ITAB2>-ippers
    AND valfr LE sy-datum
    AND valto GE sy-datum
    AND iptype = 'INJ'
    %_hints db2 '&max_blocking_factor 500&&max_in_blocking_factor 500&u2019.
    Use with care.
    Kind regards,
    Hermann

  • Using delete and FOR ALL ENTRIES

    Hi,
    We have a error message regarding the following code :
    Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
    TABLE_KEY1  = LT_TABLE_KEY1
    Could we use the For All entries with "Select" ?
    For information, the error message is "Unable to interpret "FOR". Possible causes: Incorrect spelling or comma error.
    Thank you.

    Hi,
    Check the below syntax, if you want to delete from database
    DELETE FROM sflight
    WHERE  carrid = p_carrid AND
           fldate = sy-datum AND
           seatsocc = 0.
    Just a suggestion. May be from next time you can use F1 help for syntax:
    1. Place the cursor on the delete keword in your program and press F1 - You willl get all the possible syntax for delete statement
    2. Else open the transaction ABAPDOCU, Click Keyword Help, Enter the required keyword(delete in this case) and press cont.. You will get the syntax.
    Hope thsi will help you.
    Regards,
    Swarna Munukoti.

  • Hi All,Pre-requisite of using FOR ALL ENTRIES

    Hi All,
             What are the Pre-requisite of using FOR ALL ENTRIES in the select statement .pls its Urgent .
    thanks&regards.
    Bharat

    hi,
    For using for all entries in below statement for all entries in itab_mara it will retrieve record corresponding fields of table itab_marc.
    In this case if we have duplicate records in mara .For that also it will retrieve the value in itab_marc.
    select matnr erdat from table itab_mara where matnr in s_matnr.
    if not itab_mara is initial.
    select matnr werks from table itab_marc for all entries of table itab_mara
                                                          where werks in s_werks and
                                                                    matnr in s_matnr.
    Reward with points if helpful.

  • While using for all entries its ignoring details of where condition

    i am using one select statement as follows
    SELECT ORGVEND LOTNO  INTO TABLE IT_ORG
                   FROM /BAY4/IC_IN_SEED
                   FOR ALL ENTRIES IN IT_DATA
                   WHERE LOTNO = IT_DATA-CHARG+0(9).
    its showing error as below
    In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
    how to avoid that.
    and
    we are using one field called "MITTLEWERT"
    we have declared it as type P decimals 2.
    in report we are using one statement
    SHIFT MITTELWERT LEFT DELETING LEADING ' '.
    its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid that

    Hi,
    i am using one select statement as follows
    SELECT ORGVEND LOTNO INTO TABLE IT_ORG
    FROM /BAY4/IC_IN_SEED
    FOR ALL ENTRIES IN IT_DATA
    WHERE LOTNO = IT_DATA-CHARG+0(9).
    its showing error as below
    In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
    how to avoid that.
    and
    we are using one field called "MITTLEWERT"
    we have declared it as type P decimals 2.
    in report we are using one statement
    SHIFT MITTELWERT LEFT DELETING LEADING ' '.
    its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid that
    first of all you can not use offset for for all entries which you have used in select query
    SELECT ORGVEND LOTNO INTO TABLE IT_ORG
    FROM /BAY4/IC_IN_SEED
    FOR ALL ENTRIES IN IT_DATA
    WHERE LOTNO = IT_DATA-CHARG+0(9). " You can not use IT_DATA-CHARG+0(9).
    2) field MITTLEWER you have declared as type P decimals 2.
    Keep in mind that P is not character tupe it is numeric type so it will have initial values as 0 and not ' ' (space).
    try below kind of code
    REPORT  ZTEST_UM2.
    DATA: a TYPE p DECIMALS 2 VALUE 000123 ,
          lv_with_zeros(15) TYPE c.
    WRITE: a to lv_with_zeros.
    WRITE lv_with_zeros.
    Hope above will help u.
    Regards,
    Umang mehta

  • Read data : for all entries

    wht happens if v read data using FOR ALL ENTRIES in select statement

    Hi Ankur,
    You can only use FOR ALL ENTRIES IN ...WHERE ...in a SELECT statement.
    SELECT ... FOR ALL ENTRIES IN itab WHERE cond returns the union of the solution sets of all SELECT statements that would result if you wrote a separate statement for each line of the internal table replacing the symbol itab-f with the corresponding value of component f in the WHERE condition.Duplicates are discarded from the result set. If the internal table itab does not contain any entries, the system treats the statement as though there were no WHERE cond condition, and selects all records (in the current client).
    For Example:
    SELECT *
      FROM SCARR
      INTO TABLE t_scarr.
    LOOP AT t_SCARR INTO wa_scarr.
      SELECT SINGLE *
        FROM sflight
        INTO wa_sflight
       WHERE carrid EQ wa_scarr-carrid.
      APPEND wa_sflight TO t_sflight.
    ENDLOOP.
    Instead of the Above use below code:
    SELECT *
      FROM SCARR
      INTO TABLE t_scarr.
    SELECT *
      FROM SFLIGHT
      INTO TABLE t_sflight
       FOR ALL ENTRIES IN scARR
    WHERE carrid EQ t_scarr.
    this condition, return all entries of the sflight
    Refer the Below Links for more Info:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm
    Regards,
    Sunil

Maybe you are looking for

  • Itunes says it has downloaded my apps but they don't show on my screen

    My daughter and I each have an ipod touch--hers is downloading apps but mine is not.  It says it is doing it when I plug it into the computer (I have opted to manually sync items since we share an itunes library) but the apps are not on my ipod. help

  • How to change my apple id for setting up icloud

    I just changed my Apple ID. Now I want to set up iCloud on my iPhone. But it is defaulting to my old Apple ID and I can't find a way to change it.

  • How do I stop all of the Safari spam pop-ups?

    Since I downloaded OS Yosemite, my Safari is constantly getting pop-up tabs with spam.  It is very bad and Apple was not supposed to be susceptible to such virus issues.  Someone please advise if you have the same happening and how to stop it.  Can y

  • How to create discoverer 4i user account?

    Hi All, Could anybody please tell me how to create a discoverer 4i user account so that user can log in and use the discoverer viewer? Thanks a lot!

  • Converting XDP documents into PDF web service

    http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000526.html Why there is an error and how to use this WebService? Why this WebService URL is not be connected? tks pls help me asap