Question regarding all entries

code 1 Loop at int_cntry.
             Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
            Endloop.
code2 Select * from zfligh appending table int_fligh
            For all entries in int_cntry
            Where cntry = int_cntry-cntry.
Hello Expert
i am new to sap abap i need your help regarding all entries .
it is not a good idea to write select query inside a loop. code 2 will show better performance than the code one because it fetches data from database in a one go but i want to know more details about all entries .if you know more please help
                                                                                Thanks in advance
                                                                                Chitta Ranjan Mahato
Edited by: Mahatoji on May 24, 2010 12:32 PM

HI,
its better to go for For all entries based on the performance. It will fetch the records based on the entries available in the first table. But before going for For all entries, check the first internal table with not initial, if there is no records in the first internal table then it will fetch all the records into the second internal table.
<removed by moderator>
Thanks
Arul
Edited by: Thomas Zloch on May 24, 2010 6:01 PM

Similar Messages

  • BPM question - Delete all entries in a table and Insert data

    Hello,
    I'm new to PI BPM and have this scenario to implement.
    I'm supposed to delete all entries in a table and then insert data to the same table.
    Is BPM necessary? If it is, what is the best practice to implement my scenario?
    I want to make sure that all entries were successfully deleted before insert data.
    How do I check if all entries in the table were deleted successfully before
    initiating insert.
    Thank you.
    -Won

    Hi Won,
    Yes, this is possible without BPM.
    You have to create 2 separate mappings, each for deleting & inserting the records.
    You will have 2 different Interface mappings as well.
    But in ID, create a single interface determination.
    In that, configure Deletion interface mapping first and in the second row, configure Insertion interface mapping.
    Please make sure that the parameter 'Mainain Order At runtime' is checked in interface determination.
    -Supriya.

  • Question regarding all the x58 Pro-e and memory problems

    I've notice a serious amount of issues when it comes to people not seeing all of their RAM or not getting triple-channel status.
    Before I even post my issue, I was wondering if there is a general fix for everyone experiencing these problems, because it seems I'm have the exact same issue as everyone else.

    Oh well. Its basically like I said - its the same problem most other people are having. I have 6 GB of DDR3 RAM but only 4 GB ever shows up. And it shows in Dual channel mode, when everything should be triple channel 3 x 2GB. First, here are the specs for my system, which was just recently purchased.
    Model of the motherboard: MSI X58 Pro-E LGA
    Model of the memory: G.SKILL 6GB (3 x 2GB) 240-Pin DDR3 SDRAM DDR3 1333 (PC3 10666) Triple Channel Kit
    Model of the CPU: Intel Core i7-930 Bloomfield 2.8GHz LGA 1366 130W
    Model of the GPU:  SAPPHIRE TOXIC 100282TXSR Radeon HD 5850 1GB 256-bit GDDR5
    Model of the HDD:  Western Digital Caviar Black WD1001FALS 1TB 7200 RPM SATA 3.0Gb/s
    Model of the PSU: CORSAIR CMPSU-750TX 750W ATX12V / EPS12V
    Type of Operating System: Windows 7 Home Premium 64-bit
    I have tried everything. I've updated the BIOS, I've tested each stick, I've even RMA'd the board itself, but to no avail. I have 3 sticks of RAM in each of the DIMM_A slots. Each stick is 2 GB each, but the POST never counts more than 4 GBs. I've tried adding in the sticks each one at a time in different slots; in different combinations, but nothing is working. I know the sticks work and I know the board is reading them because they show up in Memory-Z in the BIOS and in fact, in a 3rd party program called Speccy, it shows 6GB! But it still says they're running Dual channel mode.
    Here is the current BIOS I am running as shown in the POST output and model of the memory as shown on the sticker AND the model of the motherboard itself:
    BIOS: A7522IMS V8.10 030910
    RAM MODEL NUMBER: F3-10666CL9T-6GBNQ | DDR3-1333 CL 9-9-9-24 1.5v | PC3-10666 2GBX3 | 10060840076833
    MOBO MODEL NUMBER: MS-7522 | VER: 3.1
    Those are exactly what are printed on the label/sticker letter-for-letter.
    Quote from: HU16E on 04-April-10, 09:18:47
    Buy the correct RAM, don't bend any CPU socket pins, install the sticks in the correct slots, don't buy into the RAM makers claims of 'rated' performance.
    You're either implying that I've incompetently bent a socket pin when I installed the CPU, placed the RAM in DIMM slots they don't belong or need to trash the $200 RAM I've just purchased.
    Ok, assuming that ISN'T the case, what exactly are you suggesting thats supposed to be of help? You say "Buy the correct RAM" but you don't tell me what the 'correct' RAM is.

  • Question about statement for all entries

    Hi Abap experts,
    I have a question concerning the ABAP statement for all entries.
    Explanations:
    Let’s say that my source package (Source table) contains 2 types of data:
    -type1
    -type2
    I would like to use the statement select from table into internal table
    For all entries in source package
    But the where statement changes depending on the data type (2 keys when data type is 1 and only 1 key when data type is 2) .
    So that would be:
    Type1:
    Select fields
    From table into internal table
    Where field1 = source_package-field1
    And field2 = source_package-field2.
    Type2:
    Select fields
    From table into internal table
    Where field1 = source_package-field1
    How can I merge them assming that the field od data type is ftype?
    Thanks.
    Amine

    Hi amine,
    i think this is helpful for you.
    there are 2 ways  to use the for all entries...
    1. with header line:  this method is old one. in this method the internal table (ITAB) is automatically create workarea (WA) with same name, this method 1 drawback is there where we can use WA and ITAB confused that's why this is come difficult.
    2. without header line : this is nowadays we can use this method. in this method we create separate ITAb and WA. very clear this method.
    EXAMPLES:
    1.WITH HEADER LINE METHOD:
    PARAMETERS p_kunnr TYPE kna1-kunnr.
    DATA:it_kna1 LIKE kna1 OCCURS 0 WITH HEADER LINE,
          it_adrc LIKE adrc OCCURS 0 WITH HEADER LINE,
          it_adr2 LIKE adr2 OCCURS 0 WITH HEADER LINE,
          it_adr6 LIKE adr6 OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
       SELECT * FROM kna1 INTO TABLE it_kna1
          UP TO 100 ROWS.
       IF NOT it_kna1[] IS INITIAL.
         SELECT * FROM adrc INTO TABLE it_adrc
         FOR ALL ENTRIES IN it_kna1
         WHERE addrnumber = it_kna1-adrnr.
       ENDIF.
       IF NOT it_adrc[] IS INITIAL.
         SELECT * FROM adr2 INTO TABLE it_adr2
         FOR ALL ENTRIES IN it_adrc
         WHERE  addrnumber = it_adrc-addrnumber.
       ENDIF.
       IF NOT it_adr2[] IS INITIAL.
         SELECT * FROM adr6 INTO TABLE it_adr6
         FOR ALL ENTRIES IN it_adr2
         WHERE  addrnumber = it_adr2-addrnumber.
       ENDIF.
       LOOP AT it_kna1.
         READ TABLE it_adrc WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         READ TABLE it_adr2 WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         READ TABLE it_adr6 WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         WRITE : it_kna1-kunnr, it_kna1-name1, it_adrc-city1, it_adrc-street, it_adrc-po_box_reg,
                      it_adr2-telnr_long, it_adr6-smtp_addr.
       ENDLOOP.
    2. WITH OUT HEADER LINE:
    TABLES: KNA1 , ADRC.
    DATA : IT_KNA1 TYPE STANDARD TABLE OF KNA1,
            IT_ADRC TYPE STANDARD TABLE OF ADRC,
            WA_KNA1 TYPE KNA1,
            WA_ADRC TYPE ADRC.
    DATA: BEGIN OF STRTYPE ,
           CUSTMERNO LIKE KNA1-KUNNR,
           FIRSTNAME LIKE KNA1-NAME1,
           LASTNAME  TYPE NAME2,
           CITY TYPE ORT01,
           STATE TYPE REGIO,
           COUNTRY TYPE LAND1,
           ADDRESS LIKE ADRC-ADDRNUMBER,
           END OF STRTYPE.
    DATA : IT_1 LIKE TABLE OF STRTYPE.
    SELECT-OPTIONS  K_kunnr FOR kna1-kunnr NO-EXTENSION.
    SELECT * FROM KNA1 INTO TABLE IT_KNA1 WHERE KUNNR IN K_KUNNR.
    IF NOT IT_KNA1[] IS INITIAL.
    SELECT * FROM ADRC INTO WA_ADRC FOR ALL ENTRIES IN IT_KNA1 WHERE ADDRNUMBER = IT_KNA1-ADRNR.
    ENDSELECT.
    ENDIF.
    LOOP AT IT_KNA1 INTO WA_KNA1.
       READ TABLE IT_ADRC INTO WA_ADRC WITH KEY ADDRNUMBER = WA_KNA1-ADRNR.
       IF SY-SUBRC = 0.
           STRTYPE-ADDRESS = WA_ADRC-ADDRNUMBER.
       ENDIF.
    APPEND  STRTYPE TO IT_1.
       WRITE : / WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-NAME2, WA_KNA1-ORT01, WA_KNA1-REGIO, WA_KNA1-LAND1, WA_ADRC-ADDRNUMBER.
    ENDLOOP.
    regards,
    roopa.k

  • I have read all the questions regarding the "Can't send photo using iMessage".

    I have read all the questions regarding the "Can't send photo using iMessage". I followed everything and check everything that was in it. It's still the same. I am still not able to send a photo. It started happening last week. It was fine before that. There is no error message.
    It will try to send but it will get stuck just before it sends
    and the red ! will appear with the "Not Delivered" status.
    When i tap on the !, it just says "This iMessage was not delived".
    No other message or photo is sending as the same time as the photo.
    I did reset it, I checked the email address, removed it as well. Turned it off then back on. Signed out and signed back in. Wi-Fi strength is very good. iOS is 6.0.1. I checked for updates, it is up-to-date I also checked a link http://support.apple.com/kb/TS2755. It did not help at all.
    What's wrong?!?!?!?!

    It is not a matter of reconsidering the decision. There are unsolveable technical problems with trying to run a program such as Firefox on Blackberry OS. We would need Blackberry to distribute a tool similar to Android's NDK to run on Blackberries.

  • Hello, I have a question regarding the sharing/exporting on imovie. Whenever I click the share button all the normal options pop up, but when I actually click where I want to share it to nothing happens.  If you know what's wrong please let me know.

    Hello,  I have a question regarding the sharing on iMovie.  I have just recently purchased an Elgato Gaming Capture HD and I then finished my recording with that and put it into imovie.  I worked long and hard on the project and when I go click the share feature on iMovie all the noral options pop up and when I actually click where I want to share it to nothing at all happens.  If you know what is wrong/ what I am doing wrong please let me know.
    Thank you.
    PS:  I am using iMovie 10.0.6.

    /*line 957 error */
         public void select()
              for (count = 0; count <= p; count ++ )
                   if(P[count] != null){ /* validation */
                   m = (int)(P[count].getX());
                   n = (int)(P[count].getY());
                   if (Math.pow(-1, m + n) == 1)
                        piece[m][n].setBackground(wselect);
                   else
                        piece[m][n].setBackground(bselect);
              step = 2;
         }

  • Regarding SELECT FOR ALL ENTRIES AND DELETE ADJACENT DUPLICATES

    Hi,
    i got few doubts.....
        1) Is it necessary to DELETE ADJACENT DUPLICATES when we perform a SELECT FOR ALL ENTRIES ? because for all entries itself eliminates the duplicate entries?
       2) Wat Sy-subrc returns after a SELECT FOR ALL ENTRIES statement?
       I found some code where these are used
               SORT ITAB[] BY NEWKO[].
              DELETE ADJACENT DUPLICATES FORM ITAB[].
      SELECT buknr
                   kunnr
    FORM KNB1
        into table ITAB_KNB1
      FOR ALL ENTRIES IN ITAB
        where kunnr eq itab-newko.
    Regards.
    Maehsh.

    Hi Mahesh,
    To be more specific, first you should delete "adjacent duplicates" using the sorting key ( here : NEWKO ), if Itab contains other fields.
    SORT ITAB[] BY NEWKO[].
    DELETE ADJACENT DUPLICATES FORM ITAB COMPARING NEWKO.
    You can delete or not the duplicates, but, you must know that if you don't delete them in the Itab, you will retrieve them in the ITAB_KNB1.
    Concerning the return code, it works like for the "SELECT"  ( 0 = entries found / 4 = no entrie found )
    => One more thing, it's better check :
    Check not ITab[] is initial
    because, if the Itab is empty, you'll retrieve all the record of KNB1 !
    Hope this helps,
    Erwan.
    Message was edited by:
            Erwan LE BRUN

  • Regarding 'Select .... for all entries' statement

    Hi experts,
    Can anyone suggest me that whether we can use two internal tables in 'Select .... for all entries'  statement?

    Hi,
    You can use ranges instead of second for all entries.
    Eg:
    Say for example i need to write selec statement using fields from two int tables in where conidition namely itab1, itab2.
    RANGES: r_vbeln FOR wa_tab1-vbeln.
    LOOP AT itab1 INTO wa_tab1.
      r_vbeln-sign = 'I'.
      r_vbeln-option = 'EQ'.
      r_vbeln-low = wa_tab1-vbeln.
      APPEND r_vbeln.
    ENDLOOP.
    SELECT * FROM vbap INTO TABLE itab3
    FOR ALL ENTRIES IN itab2
    WHERE vbeln IN r_vbeln "range contains all vbeln from the table itab1
    AND matwa = itab2-matwa.
    Hope this helps you.
    Regards,
    Manoj Kumar P

  • Regarding select for all entries

    Hi all,
    I want to use select for all entries....
    because i have to club 3 tablese and get the data.
    I can go for inner joins but i cant use because of performmance issues.
    so can anybody help me regarding this.
    thanks and regards,
    giri.

    do this way............
    types: begin of gt_vbrk,
            vbeln type vbrk-vbeln,
            fkart type vbrk-fkart,
            knumv type vbrk-knumv,
            bukrs type vbrk-bukrs,
            waerk type vbrk-waerk,
            netwr type vbrk-netwr,
            end of gt_vbrk,
            begin of gt_vbrp,
            vbeln type vbrp-vbeln,
            posnr type vbrp-posnr,
            fkimg type vbrp-fkimg,
            meins type vbrp-meins,
            gsber type vbrp-gsber,
            netwr type vbrp-netwr,
            aubel type vbrp-aubel,
            aupos type vbrp-aupos,
            end of gt_vbrp,
            begin of gt_vbak,
            vbeln type vbak-vbeln,
            augru type vbak-augru,
            vkgrp type vbak-vkgrp,
            gsber type vbak-gsber,
            end of gt_vbak,
            begin of gt_vbap,
            vbeln type vbap-vbeln,
            posnr type vbap-posnr,
            matnr type vbap-matnr,
            netwr type vbap-netwr,
            end of gt_vbap,
    data : git_vbrk type standard table of gt_vbrk,
          git_vbrp type standard table of gt_vbrp,
          git_vbak type standard table of gt_vbak,
          git_fcode type table of gt_fcode,
          git_vbap type table of gt_vbap.
    data : wa_vbrk type gt_vbrk,
          wa_vbrp type gt_vbrp,
          wa_vbak type gt_vbak,
          wa_fcode type gt_fcode,
          wa_vbap type gt_vbap.
    select  vbeln
              fkart
              knumv
              bukrs
              waerk
              netwr
        from vbrk into table git_vbrk
        where vbeln in s_vbeln.
      if sy-subrc eq 0.
        sort git_vbrk by vbeln.
      endif.
    if not git_vbrk[] is initial.
    clear git_vbrp[].
      select  vbeln
              posnr
              fkimg
              meins
              gsber
              netwr
              aubel
              aupos
         from vbrp into table git_vbrp
         for all entries in git_vbrk
         where vbeln = git_vbrk-vbeln.
      if sy-subrc eq 0.
        sort git_vbrp by vbeln.
      endif.
    select  vbeln
              augru
              vkgrp
              gsber
        from vbak into table git_vbak
        for all entries in git_vbrp
        where vbeln = git_vbrp-aubel.
      if sy-subrc eq 0.
        sort git_vbak by vbeln.
      endif.
    reward points if helpful............

  • Doubt regarding FOR ALL ENTRIES and INDEXES

    Hi iam Aslam ..
    and i have a  doubt  ..regrding .. .
    1)   what are  the  disadvs of using FOR ALL ENTRIES
    2)  what are the disadvs of using INDEXES
    3)    what is the  disadvs of  using  Binary search ..
    4) . how can u do performance tuning ...if u have    more than one SELECT  statements  between ... Loop and Endloop .......
    please answer to these   questions   or  reply me to [email protected] ..
    thanks  in advance ..
    bye

    HI
    <b>1) what are the disadvs of using FOR ALL ENTRIES</b>
    if there is no data available for you condition mentioned in the where condition then it will retrive all the data from the database table , which we don't want , but we can solve that easily
    Ways of Performance Tuning
    1.     Selection Criteria
    2.     Select Statements
    •     Select Queries
    •     SQL Interface
    •     Aggregate Functions
    •     For all Entries
    Select Over more than one Internal table
    Selection Criteria
    1.     Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement. 
    2.     Select with selection list.
    Points # 1/2
    SELECT * FROM SBOOK INTO SBOOK_WA.
      CHECK: SBOOK_WA-CARRID = 'LH' AND
             SBOOK_WA-CONNID = '0400'.
    ENDSELECT.
    The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list
    SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
      WHERE SBOOK_WA-CARRID = 'LH' AND
                  SBOOK_WA-CONNID = '0400'.
    Select Statements   Select Queries
    1.     Avoid nested selects
    2.     Select all the records in a single shot using into table clause of select statement rather than to use Append statements.
    3.     When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index.
    4.     For testing existence , use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit. 
    5.     Use Select Single if all primary key fields are supplied in the Where condition .
    Point # 1
    SELECT * FROM EKKO INTO EKKO_WA.
      SELECT * FROM EKAN INTO EKAN_WA
          WHERE EBELN = EKKO_WA-EBELN.
      ENDSELECT.
    ENDSELECT.
    The above code can be much more optimized by the code written below.
    SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
        FROM EKKO AS P INNER JOIN EKAN AS F
          ON PEBELN = FEBELN.
    Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops  only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.
    Point # 2
    SELECT * FROM SBOOK INTO SBOOK_WA.
      CHECK: SBOOK_WA-CARRID = 'LH' AND
             SBOOK_WA-CONNID = '0400'.
    ENDSELECT.
    The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table
    SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK
      WHERE SBOOK_WA-CARRID = 'LH' AND
                  SBOOK_WA-CONNID = '0400'.
    Point # 3
    To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields . In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.
    Point # 4
    SELECT * FROM SBOOK INTO SBOOK_WA
      UP TO 1 ROWS
      WHERE CARRID = 'LH'.
    ENDSELECT.
    The above code is more optimized as compared to the code mentioned below for testing existence of a record.
    SELECT * FROM SBOOK INTO SBOOK_WA
        WHERE CARRID = 'LH'.
      EXIT.
    ENDSELECT.
    Point # 5
    If all primary key fields are supplied in the Where condition you can even use Select Single.
    Select Single requires one communication with the database system, whereas Select-Endselect needs two.
    Select Statements           contd..  SQL Interface
    1.     Use column updates instead of single-row updates
    to update your database tables.
    2.     For all frequently used Select statements, try to use an index.
    3.     Using buffered tables improves the performance considerably.
    Point # 1
    SELECT * FROM SFLIGHT INTO SFLIGHT_WA.
      SFLIGHT_WA-SEATSOCC =
        SFLIGHT_WA-SEATSOCC - 1.
      UPDATE SFLIGHT FROM SFLIGHT_WA.
    ENDSELECT.
    The above mentioned code can be more optimized by using the following code
    UPDATE SFLIGHT
           SET SEATSOCC = SEATSOCC - 1.
    Point # 2
    SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
      WHERE CARRID = 'LH'
        AND CONNID = '0400'.
    ENDSELECT.
    The above mentioned code can be more optimized by using the following code
    SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA
      WHERE MANDT IN ( SELECT MANDT FROM T000 )
        AND CARRID = 'LH'
        AND CONNID = '0400'.
    ENDSELECT.
    Point # 3
    Bypassing the buffer increases the network considerably
    SELECT SINGLE * FROM T100 INTO T100_WA
      BYPASSING BUFFER
      WHERE     SPRSL = 'D'
            AND ARBGB = '00'
            AND MSGNR = '999'.
    The above mentioned code can be more optimized by using the following code
    SELECT SINGLE * FROM T100  INTO T100_WA
      WHERE     SPRSL = 'D'
            AND ARBGB = '00'
            AND MSGNR = '999'.
    Select Statements       contd…           Aggregate Functions
    •     If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself.
    Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )
    Consider the following extract.
                Maxno = 0.
                Select * from zflight where airln = ‘LF’ and cntry = ‘IN’.
                 Check zflight-fligh > maxno.
                 Maxno = zflight-fligh.
                Endselect.
    The  above mentioned code can be much more optimized by using the following code.
    Select max( fligh ) from zflight into maxno where airln = ‘LF’ and cntry = ‘IN’.
    Select Statements    contd…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)
    Points to be must considered FOR ALL ENTRIES
    •     Check that data is present in the driver table
    •     Sorting the driver table
    •     Removing duplicates from the driver table
    Consider the following piece of extract
    Loop at int_cntry.
           Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    The above mentioned can be more optimized by using the following code.
    Sort int_cntry by cntry.
    Delete adjacent duplicates from int_cntry.
    If NOT int_cntry[] is INITIAL.
                Select * from zfligh appending table int_fligh
                For all entries in int_cntry
                Where cntry = int_cntry-cntry.
    Endif.
    Select Statements    contd…  Select Over more than one Internal table
    1.     Its better to use a views instead of nested Select statements.
    2.     To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.
    3.     Instead of using nested Select loops it is often better to use subqueries.
    Point # 1
    SELECT * FROM DD01L INTO DD01L_WA
      WHERE DOMNAME LIKE 'CHAR%'
            AND AS4LOCAL = 'A'.
      SELECT SINGLE * FROM DD01T INTO DD01T_WA
        WHERE   DOMNAME    = DD01L_WA-DOMNAME
            AND AS4LOCAL   = 'A'
            AND AS4VERS    = DD01L_WA-AS4VERS
            AND DDLANGUAGE = SY-LANGU.
    ENDSELECT.
    The above code can be more optimized by extracting all the data from view DD01V_WA
    SELECT * FROM DD01V INTO  DD01V_WA
      WHERE DOMNAME LIKE 'CHAR%'
            AND DDLANGUAGE = SY-LANGU.
    ENDSELECT
    Point # 2
    SELECT * FROM EKKO INTO EKKO_WA.
      SELECT * FROM EKAN INTO EKAN_WA
          WHERE EBELN = EKKO_WA-EBELN.
      ENDSELECT.
    ENDSELECT.
    The above code can be much more optimized by the code written below.
    SELECT PF1 PF2 FF3 FF4 INTO TABLE ITAB
        FROM EKKO AS P INNER JOIN EKAN AS F
          ON PEBELN = FEBELN.
    Point # 3
    SELECT * FROM SPFLI
      INTO TABLE T_SPFLI
      WHERE CITYFROM = 'FRANKFURT'
        AND CITYTO = 'NEW YORK'.
    SELECT * FROM SFLIGHT AS F
        INTO SFLIGHT_WA
        FOR ALL ENTRIES IN T_SPFLI
        WHERE SEATSOCC < F~SEATSMAX
          AND CARRID = T_SPFLI-CARRID
          AND CONNID = T_SPFLI-CONNID
          AND FLDATE BETWEEN '19990101' AND '19990331'.
    ENDSELECT.
    The above mentioned code can be even more optimized by using subqueries instead of for all entries.
    SELECT * FROM SFLIGHT AS F INTO SFLIGHT_WA
        WHERE SEATSOCC < F~SEATSMAX
          AND EXISTS ( SELECT * FROM SPFLI
                         WHERE CARRID = F~CARRID
                           AND CONNID = F~CONNID
                           AND CITYFROM = 'FRANKFURT'
                           AND CITYTO = 'NEW YORK' )
          AND FLDATE BETWEEN '19990101' AND '19990331'.
    ENDSELECT.
    1.     Table operations should be done using explicit work areas rather than via header lines.
    2.     Always try to use binary search instead of linear search. But don’t forget to sort your internal table before that.
    3.     A dynamic key access is slower than a static one, since the key specification must be evaluated at runtime.
    4.     A binary search using secondary index takes considerably less time.
    5.     LOOP ... WHERE is faster than LOOP/CHECK because LOOP ... WHERE evaluates the specified condition internally.
    6.     Modifying selected components using “ MODIFY itab …TRANSPORTING f1 f2.. “ accelerates the task of updating  a line of an internal table.
    Point # 2
    READ TABLE ITAB INTO WA WITH KEY K = 'X‘ BINARY SEARCH.
    IS MUCH FASTER THAN USING
    READ TABLE ITAB INTO WA WITH KEY K = 'X'.
    If TAB has n entries, linear search runs in O( n ) time, whereas binary search takes only O( log2( n ) ).
    Point # 3
    READ TABLE ITAB INTO WA WITH KEY K = 'X'. IS FASTER THAN USING
    READ TABLE ITAB INTO WA WITH KEY (NAME) = 'X'.
    Point # 5
    LOOP AT ITAB INTO WA WHERE K = 'X'.
    ENDLOOP.
    The above code is much faster than using
    LOOP AT ITAB INTO WA.
      CHECK WA-K = 'X'.
    ENDLOOP.
    Point # 6
    WA-DATE = SY-DATUM.
    MODIFY ITAB FROM WA INDEX 1 TRANSPORTING DATE.
    The above code is more optimized as compared to
    WA-DATE = SY-DATUM.
    MODIFY ITAB FROM WA INDEX 1.
    7.     Accessing the table entries directly in a "LOOP ... ASSIGNING ..." accelerates the task of updating a set of lines of an internal table considerably
    8.    If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.
    9.    "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to “ LOOP-APPEND-ENDLOOP.”
    10.   “DELETE ADJACENT DUPLICATES“ accelerates the task of deleting duplicate entries considerably as compared to “ READ-LOOP-DELETE-ENDLOOP”.
    11.   "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to “  DO -DELETE-ENDDO”.
    Point # 7
    Modifying selected components only makes the program faster as compared to Modifying all lines completely.
    e.g,
    LOOP AT ITAB ASSIGNING <WA>.
      I = SY-TABIX MOD 2.
      IF I = 0.
        <WA>-FLAG = 'X'.
      ENDIF.
    ENDLOOP.
    The above code works faster as compared to
    LOOP AT ITAB INTO WA.
      I = SY-TABIX MOD 2.
      IF I = 0.
        WA-FLAG = 'X'.
        MODIFY ITAB FROM WA.
      ENDIF.
    ENDLOOP.
    Point # 8
    LOOP AT ITAB1 INTO WA1.
      READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.
      IF SY-SUBRC = 0.
        ADD: WA1-VAL1 TO WA2-VAL1,
             WA1-VAL2 TO WA2-VAL2.
        MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.
      ELSE.
        INSERT WA1 INTO ITAB2 INDEX SY-TABIX.
      ENDIF.
    ENDLOOP.
    The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by
    LOOP AT ITAB1 INTO WA.
      COLLECT WA INTO ITAB2.
    ENDLOOP.
    SORT ITAB2 BY K.
    COLLECT, however, uses a hash algorithm and is therefore independent
    of the number of entries (i.e. O(1)) .
    Point # 9
    APPEND LINES OF ITAB1 TO ITAB2.
    This is more optimized as compared to
    LOOP AT ITAB1 INTO WA.
      APPEND WA TO ITAB2.
    ENDLOOP.
    Point # 10
    DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.
    This is much more optimized as compared to
    READ TABLE ITAB INDEX 1 INTO PREV_LINE.
    LOOP AT ITAB FROM 2 INTO WA.
      IF WA = PREV_LINE.
        DELETE ITAB.
      ELSE.
        PREV_LINE = WA.
      ENDIF.
    ENDLOOP.
    Point # 11
    DELETE ITAB FROM 450 TO 550.
    This is much more optimized as compared to
    DO 101 TIMES.
      DELETE ITAB INDEX 450.
    ENDDO.
    12.   Copying internal tables by using “ITAB2[ ] = ITAB1[ ]” as compared to “LOOP-APPEND-ENDLOOP”.
    13.   Specify the sort key as restrictively as possible to run the program faster.
    Point # 12
    ITAB2[] = ITAB1[].
    This is much more optimized as compared to
    REFRESH ITAB2.
    LOOP AT ITAB1 INTO WA.
      APPEND WA TO ITAB2.
    ENDLOOP.
    Point # 13
    “SORT ITAB BY K.” makes the program runs faster as compared to “SORT ITAB.”
    Internal Tables         contd…
    Hashed and Sorted tables
    1.     For single read access hashed tables are more optimized as compared to sorted tables.
    2.      For partial sequential access sorted tables are more optimized as compared to hashed tables
    Hashed And Sorted Tables
    Point # 1
    Consider the following example where HTAB is a hashed table and STAB is a sorted table
    DO 250 TIMES.
      N = 4 * SY-INDEX.
      READ TABLE HTAB INTO WA WITH TABLE KEY K = N.
      IF SY-SUBRC = 0.
      ENDIF.
    ENDDO.
    This runs faster for single read access as compared to the following same code for sorted table
    DO 250 TIMES.
      N = 4 * SY-INDEX.
      READ TABLE STAB INTO WA WITH TABLE KEY K = N.
      IF SY-SUBRC = 0.
      ENDIF.
    ENDDO.
    Point # 2
    Similarly for Partial Sequential access the STAB runs faster as compared to HTAB
    LOOP AT STAB INTO WA WHERE K = SUBKEY.
    ENDLOOP.
    This runs faster as compared to
    LOOP AT HTAB INTO WA WHERE K = SUBKEY.
    ENDLOOP.

  • Regarding Select using FOR ALL ENTRIES (FAEI)

    Hi all,
    Please help me with Select using FOR ALL ENTRIES (FAEI)
    Thanks in advns,
    Das.

    Hi,
    This version of the SELECT statement was the only way to join tables until SAP release 3.0E.  It is recommended that the SQL JOIN be used.  However, this is an alternate method of joining tables that may be used in some circumstances.  Remember, SQL JOIN doesn’t utilize the SAP internal database buffer.
    Example:
        SELECT EKGRP FROM T024
               INTO TABLE T_024.
        SELECT MATNR WERKS EKGRP FROM MARC
               INTO TABLE T_MARC
               FOR ALL ENTRIES IN T_024
               WHERE EKGRP = T_024-EKGRP.
    Prerequisites:
    The driver table cannot be empty. This would cause one full table scan.
    In general, keep the driver table as small and unique (in regards to the fields that would be needed for referencing in the FAEI) as possible. If duplicate entries are not deleted, identical data is read unnecessarily from the database.
    If FAEI is used, the selected field list must be a superset of all the key fields of the database tables used in SQL. This is absolutely required to avoid data loss since the DB interface in R/3 returns unique sets of the result set to the application program. Failing to ensure this may cause problems when you want to get all records from a database table that match a certain condition.
    Avoid using FAEI on a small DB table (like configuration tables). This could potentially cause full table scans for each FAEI packet. Even if it does index range scan, it is better to get data from the small DB tables by individual SELECT without the use of FAE.
    Always use FAEI in conjunction with a DB index otherwise it would cause multiple full table scans (one table scan for each FAEI packet).
    The first field(s) of the DB index should refer to the fields of the FAEI driver table in the SQL WHERE clause. Do not leave gaps between index fields in the WHERE clause. Inefficient index access will impact every FAEI packets.
    FAEI works best when retrieving a small percentage of data from a Database table. When a large percentage of data is needed, consider getting data out of the DB table without FAEI implementation, and then do additional filtration in your application
    Reward points if found helpfull...
    Cheers,
    Chandra Sekhar.

  • I have just got my iPad2 and very pleased with it. I have a question regarding the monthly (recommended) battery full charge.  Should I let the battery completely die down to nothing at all or would this be bad for my iPad?

    I have just got my iPad2 and am very pleased with it. I have a question regarding the monthly (recommended) battery full charge.  Should I let the battery completely die down to nothing at all before I plug in to recharge or would this complete drain be bad for my iPad?

    It's not bad for it - on this page www.apple.com/batteries/ipad.html it says :
    For proper reporting of the battery’s state of charge, be sure to go through at least one charge cycle per month (charging the battery to 100% and then completely running it down).

  • Question for "FOR ALL ENTRIES"

    Some materials mentioned that If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. But what's the moderate size of the table used in "FOR ALL ENTRIES"?

    Hi Dan,
    Yes the material you read is correct some ways.
    For all entries 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.
    If you using less than 1000 records then it is better to populate those entries into a range then you can use that in the select as IN option.
    If the entries are more 1000 records then it is better to use below logic
    describe table r_ebeln  lines dl_lines.
        if dl_lines >= 1.
          clear: dl_start, dl_end.
          do.
            dl_start = dl_end + 1.
            dl_end = dl_end + 1000.
            if dl_end > dl_lines.
              dl_end = dl_lines.
            endif.
            refresh: r_ebeln_temp. clear r_ebeln_temp.
            append lines of r_ebeln from dl_start to dl_end to r_ebeln_temp.
            select ebeln "PurNo
                   bukrs "ComapnyCode
                   ernam "Name
                   ekgrp "PurGRp
                   waers "Currency
                   bedat "Date
                 from ekko
                 appending  table it_ekko
                 where ebeln in r_ebeln_temp.
            if dl_end >= dl_lines.
              exit.
            endif.
          enddo.

  • For all entries against Ranges

    Hi,
    I have a question regarding a Select query where I have to select some data and then store it in table and refer it for the 2nd Select.
    eg: Select from table 1
          into itab1.
        select from table 2
       into itab2
       for all entries in itab1.
    My question is should I use a Range for the 1st select instead of an itab.The itab1 will be containing max 50 records.
    The problem with for all entries is that I cannot use 'UP TO ROWS' as it only deletes extra entries at application level and not database level. I will be selecting 1000 rows even if I want only 100 rows.
    Please let me know ur views

    From a performance perspective ranges perform better than FOR ALL ENTRIES however the number of records you can use in your range is limited. You will get a run time dump if your range size increases beyond the allowable. If you are very confident that you have not more than 50 entries in your range, I would recommend that you use the range instead of FOR ALL ENTRIES.
    An even better option would be to use a join of two tables. If you can provide specifics I could help you further.

  • Questions regarding Optimizing formulas in IP

    Dear all,
    This weekend I had a look at the webinar on Tips and Tricks for Implementing and Optimizing Formulas in IP.
    I’m currently working on an IP-implementation and encounter the following when getting more in-depth.
    I’d appreciate very much if you could comment on the questions below.
    <b>1.)</b> I have a question regarding optimization 3 (slide 43) about Conditions:
    ‘If the condition is equal to the filter restriction, then the condition can be removed’.
    I agree fully on this, but have a question on using the Planning Function (PF) in combination with a query as DataProvider.
    In my query I have a filter in the Characteristic restriction.
    It contains variables on fiscal year, version. These only allow single value entry.
    The DataProvider acts as filter for my PF. So I’d suppose I don’t need a condition for my PF since it is narrowed down on fiscal year and version by my query.
    <b>a.) Question: Is that correct?</b>
    I just one to make sure that I don’t get to many records for my PF as input. <u>How detrimental for performance is it to use conditions anyway?</u>
    <b>2.)</b> I read in training BW370 (IP-training) that a PF is executed for the currently set filter (navigational state) in the query and that characteristics that are used in restricted keyfigures are ignored in the filter.
    So, if I use version in the restr. keyfig it will be ignored.
    <b>Questions:
    a.) Does this mean that the PF is executed for all versions in the system or for the versions that are in the filter of the Characteristic Restrictions and not the currently set filter?</b>
    <b>b.) I’d suppose the dataset for the PF can never be bigger than the initial dataset that is selected by the query, right?
    c.) Is the PF executed anaway against navigational state when I use filtering? If have an example where I filter on field customer thus making my dataset smaller, but executing the PF still takes the same amount of time.
    d.) And I also encounter that the PF is executed twice. A popup comes up showing messages regarding the execution. After pressing OK, it seems the PF runs again...</b>
    <b>3.)</b> If I use variables in my Planning Function I don’t want to fill in the parameter VAR_VALUE with a value. I want to use the variable which is ready for input from the selection screen of the query.
    So when I run the PF it should use the BI-variable. It’s no problem to customize this in the Modeler. But when I go into the frontend the field VAR_VALUE stays empty and needs a value.
    <b>Question:
    a.) What do I enter here? For parameter VAR_NAME I use the variable name, but what do I use for parameter VAR_VALUE?  Also the variable name?</b>
    <b>4.)</b> Question regarding optimization 6 (slide 48) about Formulas on MultiProviders:
    'If the formula is using data of only one InfoProvider but is defined on a MultiProvider, the the complete formual should be moved to the single base InfoProvider'.
    In our case we have three cubes in the MP, two realtime and one normal one. Right now we have one AggrLevel (AL) on op of the MP.
    For one formula I can use one cube so it's better to cretae another AL with the formula based on that cube.
    For another formula I need the two <u>realtime</u> cubes. This is interesting regarding the optimization statement.
    <b>Question:
    a.) Can I use the AL on the MP then or is it better to create a <u>new</u> MP with only these two cubes and create an AL on top of that. And than create the formula on the AL based on the MP with the two cubes?</b>
    This makes the architecture more complex.
    Thanks a lot in advance for your appreciated answers!
    Kind regards, Harjan
    <b></b><b></b>

    Marc,
    Some additional questions regarding locking.
    I encounter that the dataset that is locked depends on the restrictions made in the 'Characteristic Restrictions'-part of the query.
    Restrictions in the 'Default Values'-part are not taken into account. In that case all data records of the characteristic are locked.
    Q1: Is that correct?
    To give an example: Assume you restrict customer on hierarchy node in Default Values. If you want people to plan concurrently this is not possible since all customers are locked then. When customer restriction is moved to Char Restr the system only locks the specific cutomer hier node and people can plan concurrently.
    Q2: What about variables use in restricted keyfigures like variable for fy/period? Is only this fy/period locked then?
    Q3: We'd like to lock on a navigational attribute. The nav attr is put as a variable in the filter of the Characteristic Restrictions. Does the system then only lock this selection for the nav.attr? Or do I have to change my locking settings in RSPLSE?
    Then question regarding locking of data for functions:
    Assume you use the BEx Analyzer and use the query as data_provider_filter for your planning function. You use restricted keyfigures with char Version. First column contains amount for version 1 and second column contains amount for version 2.
    In the Char Restrictions you've restricted version to values '1' and '2'.
    When executing the inputready query version 1 and 2 are locked. (due to the selection in Char Restr)
    But when executing the planning function all versions are locked (*)
    Q4: True?
    Kind regards, Harjan

Maybe you are looking for