Package size in select query

Hi all,
Can any body help for how to use package size in select statemtent.
I want to seletc record in lot of 300 form 10k records.
And i am using 4.6c version and wnat to know this statement (package size) is there in 4.6c.
I know it is in 6.0.

Hi
Package size in SELECT statements
Package size can be used to retreive a spcific number of records at a time. This can be used if you
for example only want tofinish  processing a limited amount of data at a time due to lack of memory.
The exampel below  read 50 records at a time from VBAK into an internal table, and selects the
corresponding entries from vbap into an internal table. Then the two internal tables can be
processed, and the next 50 records from VBAk can be read. remeber to reinitialize tha tables before
the next read.
Note the usage of SELECT - ENDSELECT !
REPORT  z_test                        .
TYPES:
BEGIN OF t_vbak,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
END OF t_vbak,
BEGIN OF t_vbap,
posnr  LIKE vbap-posnr,
matnr  LIKE vbap-matnr,
meins  LIKE vbap-meins,
END OF t_vbap,
BEGIN OF t_report,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
posnr  LIKE vbap-posnr,
matnr  LIKE vbap-matnr,
meins  LIKE vbap-meins,
END OF t_report.
DATA:
li_vbak   TYPE t_vbak OCCURS 0,
l_vbak    TYPE  t_vbak,
li_vbap   TYPE t_vbap OCCURS 0,
l_vbap    TYPE t_vbap,
li_report TYPE t_report OCCURS 0,
l_report  TYPE t_report.
START-OF-SELECTION.
SELECT vbeln erdat
FROM vbak
INTO TABLE li_vbak PACKAGE SIZE 50.
SELECT posnr matnr meins
FROM vbap
INTO TABLE li_vbap
FOR ALL ENTRIES IN li_vbak
WHERE vbeln = li_vbak-vbeln.
IF sy-subrc = 0.
  Now you have the two internal tables li_vbak and liÆ_vbap filled with data.
  Do something with the data - remember to reinitialize internal tables
ENDIF.
ENDSELECT.
All of the  product names here are trademarks of their respective companies.  The site
www.allsaplinks.com no way affiliated with SAP AG. We have made every effort for the content
integrity.  Information used on this site is at your own risk.
          +
REWARD IF USEFULL+ 

Similar Messages

  • Package size

    hi experts,
    please help in  usage of package size in select query  with where  clouses
    without for all enteries
    regards
    prashant

    Hi Prashant,
    Package size option in select query is useful in multiple cases:
    - When the number of records accessed by the select query for the given where clause are very large and it may slow down the performance of the program. In this case package size option is used such that data is fetched in multiple hits.
    - If the program is checking for a particular record from the database table having very large number of records without knowing the actual key. In this case package size can be used such that we can check for the existence of the required record after each fetching and can be exited from loop immediately after finding the record.
    Thanks,
    Sankar

  • Select command using package size

    Hi all,
    I have to fetch the same record comparing the records from two data base table for which i m using
    select * from dbtab1 into table  itab1 package size n
    select * from dbtab2 into itab2
    where field = itab1-field.
    endselect.
    the loop of select is executed once for second time its givin dump.
    please help.
    regards,
    Gayatri

    Hi Gayatri,
    You can try following code:
    DATA: l_itab1 LIKE itab1 OCCURS 0 WITH HEADER LINE.
    Select first data for first select statement. Then select data for second select statement outside the ***** first select statement.
    SELECT *
        FROM dbtab1
        INTO TABLE itab1
        PACKAGE SIZE n
    ENDSELECT.
    IF NOT itab1[] IS INITIAL.
       SORT itab1 by field.
       l_itab1[] = itab1[].
       SELECT *
       FOR ALL ENTRIES IN l_itab1
       FROM dbtab2
       INTO itab2
      WHERE field = l_itab1-field.
    ENDIF.
    Hope this help you.
    Regards,
    Anil
    Edited by: Anil Salekar on Feb 23, 2009 11:45 AM

  • Select query written on view giving dump

    Hi All,
    I have written the following query on COAS view in my code:
          SELECT aufnr bukrs INTO TABLE gt_aufnr
            FROM coas
              WHERE
                    aufnr IN r_aufrm AND
                    auart IN s_auart AND
                    autyp = c_autyp_01 AND
                    kokrs = c_kokrs_mbca.
    When records in range r_aufrm are too many like 6000 or so it gives me a run time error on this query - DBIF_RSQL_INVALID_RSQL. Error description says size of select query is large.
    Question : Is this bug coming because I am using the view. If i select the records on table AUFK (only table on which the view is created), will it rectify the problem?? I am asking this because it's in production and I cant make any change and test then and there.
    Note: the range r_aufrm contains two types of records for AUFNR - 1. with sign GE and others with sign LE. So I cannot use for all entries. If I still can, please tell me how?
    Thanks a looot!
    Waiting for the response,
    Navita

    Thanks All!!
    I think, this range limit has caused the problem. Range limit is 999 records.
    Just one question I have. At runtime when I check the number of entries in r_aufrm in the query, I get 6000 entries. So, does it allow 6000 records to enter the range variable even if it has a limit of 999. Is it the case that, in select query only it will throw a dump if records in range exceed 999??
    SELECT aufnr bukrs INTO TABLE gt_aufnr
    FROM coas
    WHERE
    aufnr IN r_aufrm AND
    auart IN s_auart AND
    autyp = c_autyp_01 AND
    kokrs = c_kokrs_mbca.
    Please clear my doubt.
    Thanks a lot for ur help!!!!
    Navita

  • Select query on table rcv_lots_interface is always returning null

    Hi ,
    I need a help on the below issue.
    The issue is after creating PO in Oracle 11i I receive it in MSCA application.
    When we receive it at that point data gets inserted in the table " rcv_transactions_interface " and we have written a trigger on it.
    From the trigger on table " rcv_transactions_interface " we are calling a package and in the package we have select query on "rcv_lots_interface."
    But the select query is always returning null even though we are passing the correct "interface_transaction_id " and also after the "Receiving Transaction Processor" is executed i can see data in the table " RCV_LOT_TRANSACTIONS " for the same transaction.
    Below is the sample code i am using.
    CREATE OR REPLACE TRIGGER inv.RCV_TRAN_TRIGGER
    AFTER UPDATE
    ON po.rcv_transactions_interface
    FOR EACH ROW
    WHEN (NEW.processing_status_code='PENDING'
    AND NEW.destination_type_code IN ('INVENTORY','RECEIVING')
    AND NEW.mobile_txn = 'Y')
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_user_id NUMBER;
    v_interface_transaction_id NUMBER;
    v_organization_id NUMBER;
    v_item_id NUMBER;
    v_quantity NUMBER;
    v_resp_id NUMBER;
    v_mobile_txn VARCHAR2(5);
    v_shipment_header_id NUMBER;
    v_bill_of_lading VARCHAR2(100);
    v_group_id NUMBER;
    v_header_interface_id NUMBER;
    BEGIN
    v_interface_transaction_id := :NEW.interface_transaction_id;
    v_organization_id := :NEW.to_organization_id;
    v_user_id := :NEW.created_by;
    v_item_id := :NEW.item_id;
    v_quantity := :NEW.quantity;
    v_resp_id :=fnd_profile.VALUE('RESP_ID');
    v_transaction_type := :NEW.transaction_type;
    v_mobile_txn := :NEW.mobile_txn;
    v_bill_of_lading := :NEW.bill_of_lading;
    v_group_id := :NEW.group_id;
    v_header_interface_id := :NEW.HEADER_INTERFACE_ID;
    INV.INV_RCV_TRX_PKG.INV_RCV_LABEL_GEN_PRC( v_user_id,
    v_interface_transaction_id,
    v_item_id,
    v_quantity,
    v_organization_id,
    v_resp_id,
    v_shipment_header_id,
    v_bill_of_lading,
    v_header_interface_id,
    v_group_id);
    END;
    CREATE OR REPLACE PACKAGE BODY INV.INV_RCV_TRX_PKG
    AS
    PROCEDURE INV_RCV_LABEL_GEN_PRC( p_user_id IN NUMBER,
    p_interface_transaction_id IN NUMBER,
    p_item_id IN NUMBER,
    p_quantity IN NUMBER,
    p_organization_id IN NUMBER,
    p_resp_id IN NUMBER,
    p_shipment_header_id IN NUMBER,
    p_bill_of_lading IN VARCHAR2,
    p_header_interface_id IN NUMBER ,
    p_group_id IN NUMBER
    IS
    v_user_id NUMBER;
    v_print BOOLEAN;
    v_resp_id NUMBER;
    v_resp_appl_id NUMBER;
    v_lot_num VARCHAR2(50);
    BEGIN
    BEGIN
    SELECT application_id
    INTO v_resp_appl_id
    FROM apps.fnd_responsibility_tl frt
    WHERE responsibility_id=p_resp_id;
    END;
    apps.fnd_global.apps_initialize(p_user_id, p_resp_id, v_resp_appl_id);
    BEGIN
    SELECT rli.lot_num , rli.expiration_date
    INTO v_lot_num ,
    v_expiration_date
    FROM apps.rcv_lots_interface rli
    WHERE rli.interface_transaction_id = p_interface_transaction_id ;
    EXCEPTION
    WHEN OTHERS THEN
    v_lot_num :=NULL;
    v_expiration_date :=NULL;
    apps.fnd_file.put_line(fnd_file.log,'Exception while deriving LOT Number ######### '||p_interface_transaction_id||'------'||SQLERRM);
    END;
    END;
    Need your help to understand why the below query is always returning null and what is the solution for it ?
    SELECT rli.lot_num , rli.expiration_date
    FROM apps.rcv_lots_interface rli
    WHERE rli.interface_transaction_id = p_interface_transaction_id ;
    Thanks
    Jaydeep
    Edited by: user10454886 on Mar 25, 2013 6:31 AM
    Hi ,
    I need a solution to this issue at the earliest.
    Appreciate all of your help
    Thanks
    Jaydeep

    Centinul wrote:
    There are a lot of bugs listed in Metalink with respect to wrong results and function-based indexes.
    Here are a few:
    Bug 4028186 Wrong results if function based index exists
    Bug 4717546 Wrong results / poor plan when function based index exists
    Bug 5092688 Wrong results if function based index exists
    Based on reviewing them the workarounds range from dropping the index to setting "_disable_function_based_index" to TRUE.Facinating. It seems to me that if you use the undocumented intitialization parameter you might just as well drop the FBIs too.
    Another hazard of FBIs is the Law of Unintended Consequences. 2 years ago we tried to use one to speed up a query in a PL/SQL package. Worked OK for that purpose, but an unrelated loader on the affected table ran and rand but never finished until the FBI was dropped.

  • Error in select query with package size

    Hi Experts,
    I have an issue.
    SELECT * FROM (w_tab-tablename) I
    NTO CORRESPONDING FIELDS OF TABLE <lt_data> PACKAGE SIZE 10000.
    Am splitting the table for every 10000 records,for first time the select query is successful.
    But when it comes for the second 10000 records,its throwing the following dump.
    "DBIF_RSQL_INVALID_CURSOR"
    Help Appreciated

    Hi,
       There are a few instances where you get this error.
        1) If you are debugging inside select ... endselect.
        2) You have written any of the below statements inside select ... endselect.
    Please look at the dump .. you'll find the below ..
    MESSAGE (apart from MESSAGE S...)                                       
    COMMIT WORK                                                             
    ROLLBACK WORK                                                           
    BREAK-POINT                                                             
    WAIT                                                                    
    CALL FUNCTION ... DESTINATION (synchronous RFC)                         
    CALL FUNCTION ... STARTING NEW TASK                                     
    RECEIVE RESULTS                                                         
    CALL DIALOG                                                             
    CALL SELECTION-SCREEN                                                   
    CALL TRANSACTION                                                        
    CALL SCREEN, or any other statement that results in the display of a    
    new screen                                                              
    Regards,
    Srini.

  • PACKAGE SIZE n in SELECT query

    Hi,
    When using PACKAGE SIZE n option with SELECT queries, how to determine the best/optimum value of n ? Especially when we use this for querying tables like EKPO, EKKO etc.
    Regards,
    Anand.

    > When using PACKAGE SIZE n option with SELECT queries, how to determine the best/optimum value of n ?
    The 'package size' option to the select specifies how many
    rows are returned in one chunk.
    According to ABAP-Doku, it is best to use it with an internal table:
    DATA: itab TYPE STANDARD TABLE OF SCARR WITH NON-UNIQUE
                     DEFAULT KEY INITIAL SIZE 10.
    FIELD-SYMBOLS: <FS> TYPE scarr.
    SELECT * INTO TABLE itab PACKAGE SIZE 20 FROM scarr.
      LOOP AT itab ASSIGNING <FS>.
        WRITE: / <FS>-carrid, <FS>-carrname.
      ENDLOOP.
    ENDSELECT.
    But, basically, your application's requirements determine
    what's the best value for n.
    If you don't want a lot of DB-access, you choose a high
    value for n. If you don't want a lot of data in memory, you adjust it to a lower value.
    You can also use the 'up to n rows' construct in the select to limit the number of rows fetched from the db.
    thomas

  • Select query with package size

    Hi ,
          i am trying to use select qurey with package size , to limt the data fetching .
    Can any one gives sqample code or idea select query using 'package size'.
    Advance Thanks,
    Regards
    veera

    Hi,
        SELECT vbeln erdat
        FROM vbak
        INTO TABLE li_vbak PACKAGE SIZE 50.
         SELECT posnr matnr meins
          FROM vbap
          INTO TABLE li_vbap
          FOR ALL ENTRIES IN li_vbak
          WHERE vbeln = li_vbak-vbeln.
    Hi i want  to select only from vbeln ,ie single selct query only using pakage size.200,blocks in data base ..How ?
    Regards
    veera

  • Will it improve performance if PACKAGE SIZE added to a select query?

    Hi Gurus
    While doing the performance optimization I could see that in the code it is splitting the BKPF entries selected to a package of 500 and selecting from BSEG cluster table. In effect the remaining tables are also getting hit based on the no. of entries(packets) in the selected BKPF internal table.
    Cant we use the package size 500  in the select statement instead of this spliting and hiting the tables in a do loop.
    eg:-
          SELECT x  v z
            FROM bseg
            APPENDING TABLE lt_bseg
            PACKAGE SIZE 500
            FOR ALL ENTRIES IN lt_coep
            WHERE bukrs = lt_coep-bukrs
            AND   belnr = lt_coep-belnr_fi
            AND   gjahr = lt_coep-gjahr.
    When I read the keyword documentation I saw  a note in that as " If the addition PACKAGE SIZE is specified together with FOR ALL ENTRIES, it is not passed to the database system, but is applied to the result set on the application server, after all selected rows have been read"  I did not understand the meaning of this.
    So I am confused whether I can go ahead with this approach or will go along with the already used BKPF split logic and selct from BSEG and other tables in DO loop.
    Can you please help me << removed >>.
    Thanks & Regards,
    Shinimol.
    Edited by: Rob Burbank on Sep 23, 2010 9:09 AM

    Hi,
    regarding your second doubt:
    > Second doubt is on the note I saw in key word documentation. " If the addition PACKAGE SIZE is specified together with FOR ALL ENTRIES, it is not passed to the database system, but is applied to the result set on the application server, after all selected rows have been read.  "  I couldn't understnd this. When I debugged the select with F5 it was selecting 500 each  till it reaches th end.
    > So what does it mean, we can use this option or we should not use?
    the FAE does your select in pieces and collects the result in the database interface in an inermediate buffer and
    eliminates the duplicates there. AFTER this it gives you the number of rows back to your ABAP program that are specified with package size. It simply means that the package size addition has no effect on the memory consumptionfor the intermediate
    buffer in the database interface.
    Kind regards,
    Hermann

  • Can we find the size of the query which is retrived in select operation??

    Hi,
    We run one select query and found that the query is retriving 953368 records(rows). Now is there any way to calculate how big is that query in terms of size.??
    Could you pls suggest me.
    Thanks,
    Srini....

    >
    We run one select query and found that the query is retriving 953368 records(rows)
    >
    Yes but how many different tables are involved? How many columns? What are the datatypes of the columns?
    If I run a query that returns one row it could have 900 columns defined as CHAR(4000), or one column defined as CHAR(1).
    So row length is somewhere between 1 byte and 3.6MB times 1 million rows.
    I'm guessing 1 million bytes minimum and 3.6GB on the high side.

  • How to determine package size dynamically for select - endselect statement in ABAP

    Hi All,
    I was using select- edselect with package size but i have hard coding the package size. Can any one tell me the the process to determine dynamic package size so that i can use in parallel processing.

    Hi,
    If you are looking to determine or set the value of package size dynamically then use below code for reference.
    DATA: itab TYPE TABLE OF spfli,
           wa like LINE OF itab,
           n    TYPE i.
    n = 10.
    SELECT carrid connid
    FROM   spfli
    INTO   CORRESPONDING FIELDS OF TABLE itab
    PACKAGE SIZE n.
       LOOP AT itab INTO wa.
         WRITE: / wa-carrid, wa-connid.
       ENDLOOP.
    ENDSELECT.
    If you are concerned about the performance then either use SELECT with OPEN CURSOR and CLOSE CURSOR.
    Let me know if it helped?
    Regards,
    Zuber

  • Performance : how to detrmine the package size during a select

    Hi,
    When you do a select using package size, how to determine the value of the package size.
    Thanks for your help
    Marie

    Hi marie,
    1. When you do a select using package size
    Its done when number of records is very high.
    and we don't want to fetch all records,
    IN ONE SHOT.
    2. At that time, we fetch records in BUNCHES / PACKAGES.
    3. Just copy paste to get a taste of it.
    REPORT abc.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    DATA : ctr TYPE i.
    selection screen.
    PARAMETERS : a TYPE c.
    START-OF-SELECTION.
      SELECT * FROM t001
      INTO TABLE t001
      PACKAGE SIZE 5 .
        ctr = ctr + 1.
        WRITE :/ '----
    Loop Pass # ' , ctr.
        LOOP AT t001.
          WRITE :/ t001-bukrs , t001-butxt.
        ENDLOOP.
      ENDSELECT.
    regards,
    amit m.

  • Issue in select query

    HI All experts,<br><br>
    i have  a program in which i have a select query <pre>
    SELECT  b~vertrag
              a~anlage
              a~operand
              a~saison
              a~ab
              a~ablfdnr
              a~bis
              a~wert1
      FROM ettifn AS a INNER JOIN ever AS b
      ON aanlage = banlage
      INTO TABLE li_captran PACKAGE SIZE p_pack
      WHERE a~anlage IN s_anlage
        AND a~ab <= l_date
        AND a~bis >= l_date
        AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
        AND b~einzdat <= l_date
        AND b~auszdat >= l_date.</pre><br><br>
    this query is taking a lot of time in running and we are facing lot of performance related issues
    <br><br>
    kindly guide me how i can break this into som simpler query
    <br><br>
    ettifn has 10 million records
    ever has around 5 million records .
    <br><br>
    also please tell me how much data i can store into an internal table
    can i store 5 million records in an internal table ??????
    is it good in terms of performance of a program if not please tell me what is the better way of doing dat .
    <br><br>
    also tell me how secondry indexes help in improving performance of select query
    is it good to maintain number of secondry indexes in a standard table or it decreases performance of a standard table .
    <br><br>
    <pre>
      TYPES: BEGIN OF ty_eanlh,
              anlage LIKE eanlh-anlage,
              bis LIKE eanlh-bis,
              tariftyp LIKE eanlh-tariftyp,
             END OF ty_eanlh.
      DATA: l_date TYPE datum.
      DATA: li_eanlh TYPE HASHED TABLE OF ty_eanlh WITH UNIQUE KEY anlage
                                                                   bis
                                                   WITH HEADER LINE.
      DATA: li_captran TYPE HASHED TABLE OF ty_captran WITH UNIQUE KEY vertrag
                                                                       anlage
                                                                       operand
                                                                       saison
                                                                       ab
                                                                       ablfdnr
                                                        WITH HEADER LINE.
      DATA: l_tariftyp LIKE eanlh-tariftyp.
    l_date = p_date + 6.
      l_date = p_date + 5.          "As per Terry's Request 1/23/2009
      CHECK NOT p_cap IS INITIAL.
    Get Operand Values
      SELECT  b~vertrag
              a~anlage
              a~operand
              a~saison
              a~ab
              a~ablfdnr
              a~bis
              a~wert1
      FROM ettifn AS a INNER JOIN ever AS b
      ON aanlage = banlage
      INTO TABLE li_captran PACKAGE SIZE p_pack
      WHERE a~anlage IN s_anlage
        AND a~ab <= l_date
        AND a~bis >= l_date
        AND a~operand IN ('ID-CAPLOAD','ID-OBLT')
        AND b~einzdat <= l_date
        AND b~auszdat >= l_date.
        IF sy-subrc EQ 0 AND NOT li_captran[] IS INITIAL.
       Get Rate Category
          SELECT anlage
                 bis
                 tariftyp
          FROM eanlh INTO CORRESPONDING FIELDS OF TABLE li_eanlh
          FOR ALL ENTRIES IN li_captran
          WHERE anlage = li_captran-anlage
            AND ab <= l_date
            AND bis >= l_date.
       Get POD ID
          SELECT a~anlage
                 a~int_ui
                 a~dateto
                 a~timeto
                 b~ext_ui
          INTO TABLE i_pod
          FROM euiinstln AS a INNER JOIN euitrans AS b
          ON aint_ui = bint_ui
          FOR ALL ENTRIES IN li_captran
          WHERE a~anlage = li_captran-anlage.
          IF sy-subrc EQ 0 AND NOT i_pod[] IS INITIAL.
            SORT i_pod BY anlage.
            SELECT vertrag
                   int_ui
                   serviceid
            FROM eservice
            INTO TABLE i_servicect
            FOR ALL ENTRIES IN i_pod
            WHERE int_ui = i_pod-int_ui
              AND service_start <= l_date
              AND service_end >= l_date
              AND service = 'ESUP'.
          ENDIF.
          LOOP AT li_captran.
            i_ct-anlage = li_captran-anlage.
            READ TABLE li_eanlh WITH KEY anlage = li_captran-anlage.
            IF sy-subrc EQ 0.
              i_ct-tariftyp = li_eanlh-tariftyp.
              READ TABLE i_rate WITH KEY tariftyp = i_ct-tariftyp.
              IF sy-subrc NE 0.
                CONTINUE.
              ENDIF.
            ELSE.
              i_ct-tariftyp = '0000'.
            ENDIF.
            READ TABLE i_pod WITH KEY anlage = li_captran-anlage.
            IF sy-subrc EQ 0.
              READ TABLE i_servicect WITH KEY int_ui = i_pod-int_ui.
              IF sy-subrc EQ 0.
                i_ct-serviceid = i_servicect-serviceid.
              ENDIF.
            ENDIF.
            IF li_captran-operand = 'ID-CAPLOAD'.
              i_ct-cap = li_captran-wert1.
            ELSEIF li_captran-operand = 'ID-OBLT'.
              i_ct-tran = li_captran-wert1.
            ENDIF.
            COLLECT i_ct.
            CLEAR: li_captran, i_ct.
          ENDLOOP.
        ENDIF.
      ENDSELECT.</pre><br><br>
      this code is taking a lot of time to execute and decreasing the system performance .<br><br>
    please guide me how can i increase the performance of this code .<br><br>
    Thanks in advance<br><br><br><br>
    Edited by: Matt on Oct 11, 2009 9:45 PM

    Hi matt ,
    no i am not thru bcoz of formatting i just trying to remove it and i just marked it answered so that it will not come in my unanswered because unanswered questions are limited.
    also could you please help me in this question .
    now how can i change this question to unanswerd .
    plz guide me
    Thanks in advance

  • Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query

    Hi All,
    There is a Performance issue after Upgrade from 4.7 to ECC 6.0 with a select query in a report painter.
    This query is working fine when executed in 4.7 system where as it is running for more time in ECC6.0.
    Select query is on the table COSP.
    SELECT (FIELD_LIST)
            INTO CORRESPONDING FIELDS OF TABLE I_COSP PACKAGE SIZE 1000
            FROM  COSP CLIENT SPECIFIED
            WHERE GJAHR IN SELR_GJAHR
              AND KSTAR IN SELR_KSTAR
              AND LEDNR EQ '00'
              AND OBJNR IN SELR_OBJNR
              AND PERBL IN SELR_PERBL
              AND VERSN IN SELR_VERSN
              AND WRTTP IN SELR_WRTTP
              AND MANDT IN MANDTTAB
            GROUP BY (GROUP_LIST).
       LOOP AT I_COSP      .
         COSP                           = I_COSP      .
         PERFORM PCOSP       USING I_COSP-_COUNTER.
         CLEAR: $RWTAB, COSP                          .
         CLEAR CCR1S                         .
       ENDLOOP.
    ENDSELECT.
    I have checked with the table indexes, they were same as in 4.7 system.
    What can be the reson for the difference in execution time. How can this be reduced without adjusting the select query.
    Thanks in advance for the responses.
    Regards,
    Dedeepya.

    Hi,
    ohhhhh....... lots of problems in select query......this is not the way you should write it.
    Some generic comments:
    1. never use SELECT
                       endselect.
       SELECT
      into table
       for all entries in table
      where.
       use perform statment after this selection.
    2. Do not use into corresponding fields. use exact structure type.
    3. use proper sequence of fields in the where condition so that it helps table go according to indexes.
        e.g in your case
              sequence should be
    LEDNR
    OBJNR
    GJAHR
    WRTTP
    VERSN
    KSTAR
    HRKFT
    VRGNG
    VBUND
    PARGB
    BEKNZ
    TWAER
    PERBL
    sequence should be same as defined in table.
    Always keep select query as simple as possible and perform all other calculations etc. afterwords.
    I hope it helps.
    Regards,
    Pranaya

  • Need help in optimisation for a select query on a large table

    Hi Gurus
    Please help in optimising the code. It takes 1 hr for 3-4000 records. Its very slow.
    My Select is reading from a table which contains 10 Million records.
    I am writing the select on large table and Retrieving the values from large tables by comparing my table which has 3-4 k records.
    I am pasting the code. please help
    Data: wa_i_tab1 type tys_tg_1 .
    DATA: i_tab TYPE STANDARD TABLE OF tys_tg_1.
    Data : wa_result_pkg type tys_tg_1,
    wa_result_pkg1 type tys_tg_1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1 from
    /BIC/PZREB_SDAT *******************THIS TABLE CONTAINS 10 MILLION RECORDS
    into CORRESPONDING FIELDS OF table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE***************CONTAINS 3000-4000 RECORDS
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE-/BIC/ZLITEM1.
    sort RESULT_PACKAGE by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    sort i_tab by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    loop at RESULT_PACKAGE into wa_result_pkg.
    read TABLE i_tab INTO wa_i_tab1 with key
    /BIC/ZREB_SDAT =
    wa_result_pkg-/BIC/ZREB_SDAT
    AGREEMENT = wa_result_pkg-AGREEMENT
    /BIC/ZLITEM1 = wa_result_pkg-/BIC/ZLITEM1.
    IF SY-SUBRC = 0.
    move wa_i_tab1-/BIC/ZSETLRUN to
    wa_result_pkg-/BIC/ZSETLRUN.
    wa_result_pkg1-/BIC/ZSETLRUN = wa_result_pkg-/BIC/ZSETLRUN.
    modify RESULT_PACKAGE from wa_result_pkg1
    TRANSPORTING /BIC/ZSETLRUN.
    ENDIF.
    CLEAR: wa_i_tab1,wa_result_pkg1,wa_result_pkg.
    endloop.

    Hi,
    1) RESULT_PACKAGE internal table contains any duplicate records or not bassed on the where condotion like below
    2) Remove the into CORRESPONDING FIELDS OF table instead of that into table use.
    refer the below code is
    RESULT_PACKAGE1[] = RESULT_PACKAGE[].
    sort RESULT_PACKAGE1 by /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    delete adjustant duplicate form RESULT_PACKAGE1 comparing /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1
    from /BIC/PZREB_SDAT
    into table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE1
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE1-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE1-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE1-/BIC/ZLITEM1.
    and one more thing your getting 10 million records so use package size in you select query.
    Refer the following link also For All Entry for 1 Million Records
    Regards,
    Dhina..
    Edited by: Dhina DMD on Sep 15, 2011 7:17 AM

Maybe you are looking for

  • GR/IR and Freight clearing

    how do i clear these accounts with differences. and where do i need to maintain the tollerences to charge off differences? also can anyone the steps to clear entries. Thanks ganga

  • Mail unexpectedly quits following electrical outage/improper shutdown

    Following a brief electrical outage in which my iMac improperly shutdown, Mail has repeatedly crashed. The crash seems to happen immediately following MobileMe synchronization. After the initial crash, I ran Disk Utility to repair permissions and re-

  • Itunes will not open after trying to download new software

    I went to download the new version of itunes and it said there was an error and now it wont let me open itunes at all and suggest reinstalling...will i loose my music that I have downloaded from cds and not purchased from itunes?

  • Have Nokia fixed all the issues with E90?

    Hello all. I am thinking of buying the Nokia E90. But i want to be sure of something first. I hope that you can help me Thanks. Have Nokia fixed all the problems now with the E90? The keyboard hitting the screen? The microphone? etc? How is the build

  • Table to check the T.codes usage

    Hi, I want to know the table name in R/3 which will be displaying the transaction codes usage details as i can check the current days usage in st03n by selecting the transaction profile but intend to have the list for the previous days Appreciate for