ABAP looping forever

<b>Brief explanation of problem:</b>
I have a report that processes a lot of data.  The amount of data is dependent on what the user selects on the selection screen, but even for one entry in selection criteria, there could be thousands of records and millions of loops.
The problem, in the report, seems to be that when a user selects a range of entries (A* or A00 – DZZ), the program (scheduled in background) runs for a very long time.  Typically it the execution time is less than 30-40 seconds for one entry, but even for 30 entries, the report only averages about 1,000 seconds.
When the report is selecting a large amount of data, it seems the report just keeps on running, sometimes well over 100,000 seconds.  I’m not using any DO or WHILE loops, which can run infinitely, these are simply multiple nested (large) loops, up to 8 nested loops.  I have also monitored the memory usage of the background work process; it seems the memory levels-out after a certain point (about 500MB for large amount of data) and doesn’t increase or decrease.  I just cancel the report when it gets to that point and re-run it for smaller set of entries, and that works just fine.
<b>Now the questions:</b>
1) Can anyone diagnose the problem?  Or am I just canceling the report too early?
2) Is there a limit, when reached, the ABAP program goes in some sort of infinite loop?

Hi
There is not so much to add. It is obvious that some tuning measures should be taken. Some of the following will repeat the above recommendations. However let me write:
<b>1.</b> "BINARY SEARCH" addition may make great positive effect, however do not forget to sort your tables (The standard table must be sorted in ascending order by the specified search key).
<b>2.</b> Try giving your loop conditions with 'WHERE' statement instead of using 'CHECK'.
e.g.
LOOP AT gt_itab WHERE field_1 = 'A' .
ENDLOOP .
<u>is better than</u>
LOOP AT gt_itab .
CHECK gt_itab-field_1 = 'A' .
ENDLOOP .
<b>3.</b> If it is possible to specify keys, prefer using "READ TABLE...WITH KEY..." instead of "LOOP...ENDLOOP" to read single records.
<b>4.</b> Try using "WHILE...ENDWHILE" or "DO...ENDDO" if possible for looping. "WHILE...ENDWHILE" is better if you can prefer it.
<b>5.</b> Optimize your SELECT statements if any exists inside your loops.
__a. Prefer "SELECT SINGLE..." for reading single records and "SELECT...INTO TABLE..."(array fetch) to read multiple records.
__b. Try explicitly defining the fields you want to select. e.g. "SELECT field_1 field_2" is better than "SELECT * ".
__c. Eliminate redundant selection conditions.
__d. Generate secondary indices for the relevant tables if required.
__e. Hesitate from sophisticated selection conditions.
<b>6.</b> You can code some "WRITE" statements to trace the program execution. You can see the list output at debugging session by pressing the relevant button.
<b>7.</b> Use the "Runtime Analysis Tool" (SE30) to analyze your session for a reasonable set of data to see the relational execution time comparison between logical execution blocks of your program.
<b>8.</b> Try parallel processing. You can also consider exporting/importing generated lists.
Hope you can solve your problem...
*--Serdar
[email protected]

Similar Messages

  • Hi guru's in ABAP loop with in the loop is possible

    hi guru's in ABAP loop with in the loop is possible

    Hi sri,
        it is posible clearly.
    see this code.
    data: t_spfli type table of spfli with header line,
           t_sflight type table of sflight with header line.
    select * from spfli into table t_spfli.
    select * from sflight into table t_sflight.
    loop at t_spfli.
      write:/ t_spfli-carrid,
               t_spfli-connid.
      loop at t_sfplight where carrid eq t_spfli-carrid
                                 and connid eq t_spfli-connid.
        write / t_sflight-fldate.
      endloop.
    endloop.
    Plz Reward if useful,
    Mahi.
    Message was edited by:
            Maheswari Chegu

  • PE7 Loops forever generating DVD Menu with Blue Notes template

    I have observed that PE7 will loop forever while generating the DVD Menu (when the target is either a DVD or a directory).  This will always happen when using the Blue Notes template if there are more than one main menu markers in the video to be produced.  It does not happen if there are one or no main menu markers.  It also does not happen with other menu templates.  I've confirmed this problem on multiple computers even after a fresh install of PE7.
    It starts to loop after all the media has been processes right at the beginning of the write to the DVD or directory.
    Where can I get a Blue Notes template that works properly?

    I don't think a screen capture will help.  The problem happens with any test file that has two main menu markers on it.  This causes the blue notes template to duplicate the main menu with one marker on each.  If it makes a difference, I'm using a 16:9 aspect ratio for the video project.
    My Blue Notes _mm template is dated 9/16/08 and is 3,855,333 bytes (same as your 3.765 KB in the explorer view).  This happens with or without any scene menu(s) present.  My guess is a bug in the Blue Note main template.

  • Why does sync loop forever ?

    I noticed that sometimes Sync (with mac) loops forever ? Any reason why and possible fixes ? I don't want to reset sync history every day.

    I noticed that sometimes Sync (with mac) loops forever ? Any reason why and possible fixes ? I don't want to reset sync history every day.

  • ABAP Loop Question for next record

    Hello All, I am new to ABAP so please forgive this basic question. The below is a snippet of code I have in a ABAP Proxy.
    Here is a snippet of my code:
    DATA: ls_item    TYPE ZSHOPPING_CART_IN_BBP_PDS_SC_I.
    DATA: i_item     TYPE TABLE OF bbp_pds_sc_item_icu.
    DATA: w_item     TYPE bbp_pds_sc_item_icu.
    LOOP AT input-I_ITEM-item INTO ls_item.
        CLEAR w_item.
        w_item-guid = v_item_guid.
        w_item-parent = v_header_guid.
        w_item-description = ls_item-description.
        w_item-number_int = ls_item-number_int.
        w_item-category = ls_item-category.
        w_item-category_id = ls_item-category_id.
        w_item-product_type = ls_item-product_type.
      APPEND w_item TO i_item.
      ENDLOOP.
    The structure input-I_ITEM-item is an input from a ABAP Proxy. This all works great if I feed in only 1 line item to proxy, but if I send in two line items the result is i_item has line item 1 twice, and I get nothing for line item2. It is almost like the the loop runs twice but the ls_item stays on line 1. I am sure I am missing something simple.

    Here is a snippet of the XML I am sending to ABAP proxy:
    <I_ITEM>
         <item>
              <GUID>00000000000000000000000000055556</GUID>
              <PARENT>00000000000000000000000000055555</PARENT>
              <NUMBER_INT>0000000001</NUMBER_INT>
              <DESCRIPTION>Proxy Test Line</DESCRIPTION>
              <CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
              <CATEGORY_ID>03000</CATEGORY_ID>
              <PRODUCT_TYPE>01</PRODUCT_TYPE>
         </item>
         <item>
              <GUID>00000000000000000000000000055557</GUID>
              <PARENT>00000000000000000000000000055555</PARENT>
              <NUMBER_INT>0000000002</NUMBER_INT>
              <DESCRIPTION>Proxy Test Line  2</DESCRIPTION>
              <CATEGORY>268CA1C5BB9965449BED8C9B49484999</CATEGORY>
              <CATEGORY_ID>03000</CATEGORY_ID>
              <PRODUCT_TYPE>01</PRODUCT_TYPE>
              </item>
    </I_ITEM>

  • HR ABAP: LOOP AT SCREEN: Multiple Fields Disabling.

    Experts,
    Am a new member in the world of SAP ABAP!
    Need ur advice regarding.
    Have coded following for disabling a field in PBO based on subtypes.
        IF p9235-subty = GC_AICTD.
          IF screen-name = 'P9235-ZZ_RC_MDE'.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDIF.
    This disables the particular field mentioned in the screen name.
    If i want more than on field names to be disabled under single validation, then what should i do?
    Your help to this fresher would be appreciated!
    Points will be definitely rewarded for your help and time...
    Thank you.
    Sundar.

    *&      Module  display  OUTPUT
          text
    MODULE display OUTPUT.
    *break-point.
    loop at screen.
    if create = 'X'.
      if screen-group1 = 'XXX'.
      screen-input = 1.
      modify screen.
      endif.
    endif.
    if display = 'X'.
      if screen-group2 = 'YYY'.
    screen-input = 0.
      modify screen.
      endif.
    endif.
      endloop.
    ENDMODULE.                 " display  OUTPUT
    but declare the group!

  • ABAP loop inside eCATT

    Hello Colleagues,
    I want to read multiple values from a table and display for which i going thru an loop .
    But to display it is becoming an problem can you kindly see the code below .
    Am trying to store the table fields in an table as mentioend below in the ABAP  ENDABAP code.
    V_C3[]-TABLE_LINE = <fs_field>.
    But i am getting an error while compiling the code.
    Can you suggest the solution for the same ?
    loop at <fs_itab> assigning <fs_wa>.
            assign component 'CLIENT' of structure <fs_wa> to <fs_field>.
            V_CLIENT = <fs_field>.
            assign component 'C0' of structure <fs_wa> to <fs_field>.
            V_C0 = <fs_field>.
            assign component 'C1' of structure <fs_wa> to <fs_field>.
            V_C1 = <fs_field>.
            assign component 'C2' of structure <fs_wa> to <fs_field>.
            V_C2 = <fs_field>.
            assign component 'C3' of structure <fs_wa> to <fs_field>.
            V_C3[]-TABLE_LINE = <fs_field>.
            assign component 'C4' of structure <fs_wa> to <fs_field>.
            V_C4 = <fs_field>.
            assign component 'C5' of structure <fs_wa> to <fs_field>.
            V_C5 = <fs_field>.
            assign component 'C6' of structure <fs_wa> to <fs_field>.
            V_C6 = <fs_field>.
            assign component 'C7' of structure <fs_wa> to <fs_field>.
            V_C7 = <fs_field>.
            assign component 'C8' of structure <fs_wa> to <fs_field>.
            V_C8 = <fs_field>.
            assign component 'MESSAGE_ID' of structure <fs_wa> to <fs_field>.
            V_MESSAGE_ID = <fs_field>.
            assign component 'TIMESTAMP' of structure <fs_wa> to <fs_field>.
            V_TIMESTAMP = <fs_field>.
            assign component 'EXTRACTKEY' of structure <fs_wa> to <fs_field>.
            V_EXTRACTKEY = <fs_field>.
            assign component 'STATEID' of structure <fs_wa> to <fs_field>.
            V_STATEID = <fs_field>.
            assign component 'DEVICE_ID' of structure <fs_wa> to <fs_field>.
            V_DEVICE_ID = <fs_field>.
          ENDLOOP.
    regards
    harsha

    Hello Harsha,
    This task can be performed in more simpler way if i understand your requirements correctly.
    Inside ABAP ... ENDABAP statements use Select statement and read all the values from your target table and assign it to a Local variable of the same table type.
    Note : Import & Export variables cannot be used inside the ABAP ... ENDABAP statement.
    Once all the values are stored in the Local table , outside the ENDABAP statement you can assign directly to the Export variable of table type with the local variable.
    This export variable becomes visible outside the script asusual.
    This should solve your requirment.
    Thanks & Best regards,
    Ajay

  • SetInterval repeat when finished looping forever

    Greetings,
    The following setInterval example is right out of the Flash
    documentation, and I'm using this method to periodically, create,
    animate and fade out (using the tween class) some items on screen
    This code from the docs traces the contents of an array,
    passed as parameters, at one second intervals. What is the best way
    to have it start again when completed, thus beginning again to
    trace the first parameter-- and so on forever looping.
    Thanks in advance to all you AS experts.

    Yes, it does seem to be one of those things that a lot of
    folks struggle with – I did too way back.
    Just remember that it means, "keep doing what I tell you at
    the agreed upon interval – until you are told to stop." I
    think assigning the return value to a variable is a big part of the
    confusion. Really it is just like getting a ticket in a bakery.
    There can be many interval running at the same time, so to keep
    them straight flash gives them a number – the first one is 1,
    the next 2, and so on.
    So all that we are doing with the assigning to a variable is
    pulling the bakery ticket out of the machine and hanging on to it.
    There is no way to know what the number will be until we pull it
    out or what it was if we lose it. So we have to keep it around (by
    putting it in a variable). Then later we can say, "Oh yeah,
    remember interval 5, well cancel it now."
    Remember too, that the internal Flash classes may also use
    setInterval so you can never count on, "Well the last interval I
    used was 4, so this next one will be 5."

  • Menu loops forever

    Hi,
    I have the following problem with Encore DVD 1.5.1:
    I want to create a menu with audio background. The audio file should only play once, so I set the loop to none. However, no matter what I set for the loop count, it always repeats the music title forever!
    Any ideas?
    I have Encore DVD 2.0 also, but it's completely unusuable because it freezes as soon as I import an (already DVD-compliant!) MPEG2-file.
    Thanks,
    Sven

    I figured this one out by myself: It's not a bug, it's simply a missing feature! You can tell an animated button to stop after a specific number of loops, but not the background audio!
    This topic can be moved to the feature requests.
    Sven

  • I can't get updates to work. it just loops forever

    i have a macbook air. when i get prompted to update, it loops forever

    Hello,
    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • ABAP Loop/read statement

    Hello All-
    I'm writing a loop and a read statement between two tables.  What I am trying to do is flag certain records that exsist in one table but NOT in the other.  For example, I have table /BIC/PG_ICODE  which is the P table for Global ICODE and I also have a "z" table which hold all "valid" icodes. My logic is as follows: If an icode exsists in the P table AND also exsists in the "Z" table then I don't want to do anything with this record. But if it exsists in the P table but NOT in the "z" table then I want to insert this ICODE into an E_T_RANGE table.  What I have done here is created a FM which will be called in a QUERY that I have built.  The problem is that after the code is executed and I look at the records in the E_T_RANGE table, I find some icodes that exsist both in the P table and "z" table.  The E_T_RANGE table should only contain icodes that exsist in the P table and NOT the "z" table. Can someone please have a look at my code and tell me what I am doing wrong?
    DATA : L_S_RANGE LIKE E_T_RANGE,
           IT_ICODE TYPE standard table of /BIC/TG_ICODE,
           IT_PTABLE TYPE standard table of /BIC/PG_ICODE,
           it_ZVALID_ICODES TYPE standard table of   ZVALID_ICODES,
           wa_ZVALID_ICODES TYPE ZVALID_ICODES,
           l_sign type c value 'I',
           wa type /BIC/TG_ICODE,
           wa2 type /BIC/PG_ICODE.
    SELECT /BIC/G_ICODE FROM /BIC/PG_ICODE INTO
        CORRESPONDING FIELDS OF table IT_PTABLE where /BIC/G_ICODE like
    'I%'.
    sort IT_PTABLE by /BIC/G_ICODE.
    SELECT /BIC/G_ICODE FROM ZVALID_ICODES INTO
        CORRESPONDING FIELDS OF table IT_ZVALID_ICODES.
    sort IT_ZVALID_ICODES by /BIC/G_ICODE.
    loop at IT_PTABLE into wa2.
    read table IT_ZVALID_ICODES with key
    /BIC/G_ICODE = wa2-/BIC/G_ICODE into wa_ZVALID_ICODES.
    if sy-subrc ne 0.
            L_S_RANGE-LOW = wa_ZVALID_ICODES-/BIC/G_ICODE.
            L_S_RANGE-SIGN = l_sign.
            L_S_RANGE-OPT = 'EQ'.
    DELETE ADJACENT DUPLICATES FROM E_T_RANGE.
          APPEND L_S_RANGE TO E_T_RANGE.
    endif.
    endloop.
    ENDFUNCTION.

    Hi try the following code...
    DATA : L_S_RANGE LIKE E_T_RANGE,
    IT_ICODE TYPE standard table of /BIC/TG_ICODE,
    IT_PTABLE TYPE standard table of /BIC/PG_ICODE,
    it_ZVALID_ICODES TYPE standard table of ZVALID_ICODES,
    wa_ZVALID_ICODES TYPE ZVALID_ICODES,
    l_sign type c value 'I',
    wa type /BIC/TG_ICODE,
    wa2 type /BIC/PG_ICODE.
    SELECT /BIC/G_ICODE FROM /BIC/PG_ICODE INTO
    CORRESPONDING FIELDS OF table IT_PTABLE where /BIC/G_ICODE like
    'I%'.
    sort IT_PTABLE by /BIC/G_ICODE.
    DELETE ADJACENT DUPLICATES FROM IT_PTABLE.
    SELECT /BIC/G_ICODE FROM ZVALID_ICODES INTO
    CORRESPONDING FIELDS OF table IT_ZVALID_ICODES.
    sort IT_ZVALID_ICODES by /BIC/G_ICODE.
    DELETE ADJACENT DUPLICATES FROM IT_ZVALID_ICODES.
    loop at IT_PTABLE into wa2.
    read table IT_ZVALID_ICODES with key
    /BIC/G_ICODE = wa2-/BIC/G_ICODE into wa_ZVALID_ICODES
             binary search.
    if sy-subrc ne 0.
    L_S_RANGE-LOW = wa_ZVALID_ICODES-/BIC/G_ICODE.
    L_S_RANGE-SIGN = l_sign.
    L_S_RANGE-OPT = 'EQ'.
    APPEND L_S_RANGE TO E_T_RANGE.
    endif.
    endloop.
    sort e_t_range.
    DELETE ADJACENT DUPLICATES FROM E_T_RANGE.
    ENDFUNCTION.
    Regards,
    Suresh Datti

  • ABAP Looping technique

    Hi,
    I want to calculate margin percentage based on line item wise & subtotal wise for a billing doc/sales doc.
    I have already accomplish line item wise & working fine.  Problem occurs when I want it to be print subtotal wise.
    I have applied logic to calculate subtotals but loop is not working properly though not getting any errors but not getting desired output ,instead I am getting same output in as getting in percentage line item wise but ideally figure should be different in % if we are calculating it line item wise & subtotal wise.

    Hi Drasthi,
    Sample code,
    REPORT  ZPRODUCT.
    TYPE-POOLs: slis.
    data: lv_p TYPE p DECIMALS 2,
           it_fcat TYPE slis_t_fieldcat_alv,
           wa_fcat TYPE slis_fieldcat_alv.
    data: BEGIN OF itab OCCURS 0,
           lv_per TYPE string,
           END OF itab.
    START-OF-SELECTION.
    lv_p = '12.0'.
    if lv_p is not initial.
    MOVE lv_p to itab-lv_per.
    CONCATENATE itab-lv_per '%' INTO itab-lv_per.
    APPEND itab.
    endif.
    wa_fcat-fieldname = 'LV_PER'.
    APPEND wa_fcat to it_fcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM                = sy-repid
        IT_FIELDCAT                       = it_fcat
       TABLES
         T_OUTTAB                          = itab[]
    * EXCEPTIONS
    *   PROGRAM_ERROR                     = 1
    *   OTHERS                            = 2
    Regards,
    Venkat.

  • Looping bubbles so it loops forever - Particle system

    Hi guys,
    Is it possible to loop bubbles, using the foam particle ? I want a glass of champagne and want the bubbles to loop, and never stop.
    Let's say you want to loop this over and over, so it seems seemless ?
    I don't see a way to accomplish this, as the bubbles are never the same on any frame. If you just cut out a portion of a rendered video, you will see it has been snipped. The bubbles will never match up.
    How would one go about this ?
    Thanks for any information,
    Dave.
    P.S. - there are so many AE forums, which one is the best to post in ? - where the most chat is going on ? It may be where I posted, but I'm not sure.

    [email protected] wrote:
    > Hi guys,
    >
    > Is it possible to loop bubbles, using the foam particle ? I want a glass of champagne and want the bubbles to loop, and never stop.
    >
    > Let's say you want to loop this over and over, so it seems seemless ?
    >
    > I don't see a way to accomplish this, as the bubbles are never the same on any frame. If you just cut out a portion of a rendered video, you will see it has been snipped. The bubbles will never match up.
    >
    > How would one go about this ?
    >
    > Thanks for any information,
    >
    > Dave.
    >
    > P.S. - there are so many AE forums, which one is the best to post in ? - where the most chat is going on ? It may be where I posted, but I'm not sure.
    I have not watched the podcast, but the title sounds promising.
    http://cowcast.creativecow.net/podcast/creating-a-looping-particle-system--250

  • How Can I Create a Menu Where the Audio Loops Twice But the Video Loops Forever

    I'm wanting to create a 50 second looping menu with a video background and some music, but I only want the music to play twice.  After the second time the music plays, I'd like the video background to continue looping, but not have any music.
    How could I achieve this while giving the user the ability to make menu selections at any time?  I've seen it done on a number of commerically available DVDs and Blu-rays, but I can't figure out how to do it in Encore.
    I'm using Encore CS6.
    Thanks.

    Stan Jones wrote:
    I do not know if that works, but I don't see why it wouldn't.
    I'm not sure what you're referring to.  Are you referring the commercially available DVDs that I've seen achieving what I mentioned in the first post? 
    There's definately a way to do this, but perhaps Encore just insn't capable. I always find it annoying when a DVD menu loops music or some other audio infinately.  I may stick a disc in the player and walk into the other room to do something while it's loading up.  I always appreciate it when whoever made the disc only has the music or audio looping a couple of times, then it stops.
    Just wish I could do the same.

  • Target Discovery Loop Forever - OEM10g R2 Grid Control Solaris

    I have installed GC 10g R2 on a Solaris 64 bits.
    The OEM got installed ok, but in near the end the agent gets hung in the target discovery step of the configuration.
    I stoped the assitant, clear al the info in sysman/emd, clearstate de agent, started it and force de upload.
    Whith this actions I got the agent configured in the OEM, then I go to the page for the discovering the targets... but again it enter in a non ending loop.
    I tried also de agentca -d, again.. it get hung.
    Did someone have had this problem? Any Help?
    Message was edited by:
    jotawolf

    I have 8i and 9i databases, 9ias, etc. on a windows box. I have 10g R2 grid control on my linux server. I wish to install the windows 10g R2 agent on the windows box (during install windows agent found oms under linux after I supplied host/connect info) and I assumed when the agent started up (first time) under windows that it would auto-discover the 9i and 8i services on the windows box then forward that data to the oms under linux, but it didn't... I didn't even see the windows agent registered under the linux oms.
    Did I miss something? Do I need to install an oms (and agent) under windows as well. Thought I just needed the 10g R2 (windows) agent only.
    Any advice is appreciated.

Maybe you are looking for