<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: removing loop from loop. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675115#M885056</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             Performance Tuning using parallel cursor&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Extracts from program ZFAL2002&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;START-OF-SELECTION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;  INTO TABLE I_KEPH FROM KEPH&lt;/P&gt;&lt;P&gt;  WHERE KADKY &amp;lt;= SY-DATUM&lt;/P&gt;&lt;P&gt;    AND TVERS = '01'&lt;/P&gt;&lt;P&gt;    AND KALKA IN ('01','Z1','Z2')&lt;/P&gt;&lt;P&gt;    AND BWVAR IN ('Z01','Z02','Z03','Z04','Z07')&lt;/P&gt;&lt;P&gt;    AND KKZST = ' '&lt;/P&gt;&lt;P&gt;    AND KKZMA = ' '&lt;/P&gt;&lt;P&gt;    AND KKZMM = ' '&lt;/P&gt;&lt;P&gt;    AND KEART = 'H'&lt;/P&gt;&lt;P&gt;    AND PATNR = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Table must be sorted to ensure all required records are together&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SORT I_KEPH BY KALNR KALKA BWVAR KADKY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Perform actual processing&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  Perform get_cost_values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_COST_VALUES.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Determine start position and then process all records for given key&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;from that starting point&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;i_keph is sorted on kalnr kalka bwvar kadky.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  READ TABLE I_KEPH WITH KEY KALNR = W_KEKO-KALNR&lt;/P&gt;&lt;P&gt;                             KALKA = W_KEKO-KALKA&lt;/P&gt;&lt;P&gt;                             BWVAR = W_KEKO-BWVAR&lt;/P&gt;&lt;P&gt;                             KADKY = W_KEKO-KADKY BINARY SEARCH.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Loop at itab from first record found (sy-tabix) until record&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;no-longer matches your criteria.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    LOOP AT I_KEPH FROM SY-TABIX.&lt;/P&gt;&lt;P&gt;      IF  I_KEPH-KALNR = W_KEKO-KALNR AND I_KEPH-KALKA = W_KEKO-KALKA&lt;/P&gt;&lt;P&gt;      AND I_KEPH-BWVAR = W_KEKO-BWVAR AND I_KEPH-KADKY = W_KEKO-KADKY.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Key match&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        D_MAT_COST = D_MAT_COST + I_KEPH-KST001.&lt;/P&gt;&lt;P&gt;        D_LAB_COST = D_LAB_COST + I_KEPH-KST004.&lt;/P&gt;&lt;P&gt;        D_OVER_HEAD = D_OVER_HEAD + I_KEPH-KST010.&lt;/P&gt;&lt;P&gt;        D_EXT_PURCH = D_EXT_PURCH + I_KEPH-KST014.&lt;/P&gt;&lt;P&gt;        D_MISC_COST = D_MISC_COST + I_KEPH-KST002 + I_KEPH-KST003&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST005 + I_KEPH-KST006 + I_KEPH-KST007&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST008 + I_KEPH-KST009 + I_KEPH-KST011&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST012 + I_KEPH-KST013 + I_KEPH-KST015&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST016 + I_KEPH-KST017 + I_KEPH-KST018&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST019 + I_KEPH-KST020 + I_KEPH-KST021&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST022 + I_KEPH-KST023 + I_KEPH-KST024&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST025 + I_KEPH-KST026 + I_KEPH-KST027&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST028 + I_KEPH-KST029 + I_KEPH-KST030&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST031 + I_KEPH-KST032 + I_KEPH-KST033&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST034 + I_KEPH-KST035 + I_KEPH-KST036&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST037 + I_KEPH-KST038 + I_KEPH-KST039&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST040.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Key greater - can't be less&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        EXIT.                                               " Exit loop&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  D_MAT_COST  = D_MAT_COST  / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_LAB_COST  = D_LAB_COST  / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_OVER_HEAD = D_OVER_HEAD / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_EXT_PURCH = D_EXT_PURCH / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_MISC_COST = D_MISC_COST / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;ENDFORM.                               " GET_COST_VALUES&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Apr 2008 04:52:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-04-15T04:52:39Z</dc:date>
    <item>
      <title>removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675107#M885048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can any one help me on this issue,&lt;/P&gt;&lt;P&gt;i have to remove the loop on bseg ans so that i can add .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; CLEAR : w_debit  ,&lt;/P&gt;&lt;P&gt;            w_credit .&lt;/P&gt;&lt;P&gt;    LOOP AT wtl_temp ASSIGNING &amp;lt;fs&amp;gt;.&lt;/P&gt;&lt;P&gt;      READ TABLE wtl_prctr WITH KEY bukrs = &amp;lt;fs&amp;gt;-bukrs&lt;/P&gt;&lt;P&gt;                                    belnr = &amp;lt;lfs&amp;gt;-belnr&lt;/P&gt;&lt;P&gt;                                    gjahr = &amp;lt;lfs&amp;gt;-gjahr&lt;/P&gt;&lt;P&gt;                                    prctr = &amp;lt;lfs&amp;gt;-prctr&lt;/P&gt;&lt;P&gt;                                    hkont = &amp;lt;lfs&amp;gt;-hkont            &lt;/P&gt;&lt;P&gt;                                TRANSPORTING NO FIELDS.&lt;/P&gt;&lt;P&gt;      IF sy-subrc NE 0.&lt;/P&gt;&lt;P&gt;        MOVE : &amp;lt;lfs1&amp;gt;-bukrs TO wsl_prctr-bukrs,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs&amp;gt;-belnr TO wsl_prctr-belnr,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs&amp;gt;-gjahr TO wsl_prctr-gjahr,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs&amp;gt;-prctr TO wsl_prctr-prctr,&lt;/P&gt;&lt;P&gt;               &amp;lt;fs&amp;gt;-hkont TO wsl_prctr-hkont.                          &lt;/P&gt;&lt;P&gt;      LOOP AT wt_bseg ASSIGNING &amp;lt;fs2&amp;gt; WHERE bukrs EQ &amp;lt;fs&amp;gt;-bukrs&lt;/P&gt;&lt;P&gt;                                          AND belnr EQ &amp;lt;fs&amp;gt;-belnr&lt;/P&gt;&lt;P&gt;                                          AND gjahr EQ &amp;lt;fs&amp;gt;-gjahr&lt;/P&gt;&lt;P&gt;                                          AND prctr EQ &amp;lt;fs&amp;gt;-prctr&lt;/P&gt;&lt;P&gt;                                          AND hkont EQ &amp;lt;fs&amp;gt;-hkont.  &lt;/P&gt;&lt;P&gt;          CASE &amp;lt;fs2&amp;gt;-shkzg.&lt;/P&gt;&lt;P&gt;            WHEN c_debit .&lt;/P&gt;&lt;P&gt;              w_debit  = w_debit  + &amp;lt;fs2&amp;gt;-dmbtr.&lt;/P&gt;&lt;P&gt;            WHEN c_credit.&lt;/P&gt;&lt;P&gt;              w_credit = w_credit + &amp;lt;fs2&amp;gt;-dmbtr.&lt;/P&gt;&lt;P&gt;          ENDCASE.&lt;/P&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;P&gt;        wsl_prctr-dmbtr = w_credit - w_debit.&lt;/P&gt;&lt;P&gt;        APPEND wsl_prctr TO wtl_prctr.&lt;/P&gt;&lt;P&gt;        CLEAR : wsl_prctr  ,&lt;/P&gt;&lt;P&gt;                w_debit   ,&lt;/P&gt;&lt;P&gt;                w_credit  .&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;P&gt;        CONTINUE.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 13:10:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675107#M885048</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T13:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675108#M885049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;avoid loop on that table and put &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;READ TABLE wt_bseg with key bukrs EQ &amp;lt;fs&amp;gt;-bukrs&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this will improve ur performnce also&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 13:20:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675108#M885049</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T13:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675109#M885050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi naresh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;as u told it is correct,but i have lot many records with same belnr in the bseg.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 13:25:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675109#M885050</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675110#M885051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;u can use &lt;STRONG&gt;parallel Cursor method&lt;/STRONG&gt; here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if it is compulsory to use nested loops, then we need to go for &lt;STRONG&gt;PARALLEL CURSOR METHOD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;this is very efficient method. This decreases the execution time and increases the performance.&lt;/P&gt;&lt;P&gt;here is a sample code for &lt;STRONG&gt;PARALLEL CURSOR METHOD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nested Loops &amp;#150; This is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Program using Normal Nested Loop:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT ZNORMAL_NESTEDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;likp,&lt;/P&gt;&lt;P&gt;lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;/P&gt;&lt;P&gt;t_likp type table of likp,&lt;/P&gt;&lt;P&gt;t_lips type TABLE OF lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data:&lt;/P&gt;&lt;P&gt;W_RUNTIME1 TYPE I,&lt;/P&gt;&lt;P&gt;W_RUNTIME2 TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from likp&lt;/P&gt;&lt;P&gt;into table t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from lips&lt;/P&gt;&lt;P&gt;into table t_lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;get RUN TIME FIELD w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at t_likp into likp.&lt;/P&gt;&lt;P&gt;loop at t_lips into lips where vbeln eq likp-vbeln.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;get RUN TIME FIELD w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_runtime2 = w_runtime2 - w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Nested Loop using Parallel Cursor:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT zparallel_cursor2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TABLES:&lt;/P&gt;&lt;P&gt;likp,&lt;/P&gt;&lt;P&gt;lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;t_likp TYPE TABLE OF likp,&lt;/P&gt;&lt;P&gt;t_lips TYPE TABLE OF lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;w_runtime1 TYPE i,&lt;/P&gt;&lt;P&gt;w_runtime2 TYPE i,&lt;/P&gt;&lt;P&gt;w_index LIKE sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM likp&lt;/P&gt;&lt;P&gt;INTO TABLE t_likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM lips&lt;/P&gt;&lt;P&gt;INTO TABLE t_lips.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD w_runtime1.&lt;/P&gt;&lt;P&gt;SORT t_likp BY vbeln.&lt;/P&gt;&lt;P&gt;SORT t_lips BY vbeln.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_likp INTO likp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT t_lips INTO lips FROM w_index.&lt;/P&gt;&lt;P&gt;IF likp-vbeln NE lips-vbeln.&lt;/P&gt;&lt;P&gt;w_index = sy-tabix.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;GET RUN TIME FIELD w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;w_runtime2 = w_runtime2 - w_runtime1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE w_runtime2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Analysis report:&lt;/STRONG&gt; Runtime in microseconds: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Iteration No&lt;/U&gt; ....._Normal Nest Loop_ ..... &lt;U&gt;Using Parallel Cursor&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 ....................... 34,796,147 ................... 63,829 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2 .........................38,534,583 ................... 56,894 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3 .........................34,103,426 ................... 50,510 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can check this site for more details&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ABAP/ParallelCursor.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;reward if helpful&lt;/P&gt;&lt;P&gt;raam&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 13:41:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675110#M885051</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T13:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675111#M885052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another choice could be defining your internal table as SORTED.&lt;/P&gt;&lt;P&gt;A loop with specified key on a sorted table should loop only on the relevant part of the table.&lt;/P&gt;&lt;P&gt;Just change table definition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: wt_bseg TYPE SORTED TABLE OF BSEG WITH NON-UNIQUE KEY &lt;/P&gt;&lt;P&gt;                                 BUKRS BELNR GJHAR PRCTR HKONT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should not modify your loop.&lt;/P&gt;&lt;P&gt;If you select from BSEG into wt_bseg with "INTO TABLE" option you should not modify your code.&lt;/P&gt;&lt;P&gt;If you select from BSEG into wt_bseg with "APPEND" statement, you should replace your &lt;/P&gt;&lt;P&gt;"APPEND &amp;lt;WA&amp;gt; TO WT_BSEG" code with "INSERT &amp;lt;WA&amp;gt; INTO TABLE WT_BSEG" code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 14:08:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675111#M885052</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T14:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675112#M885053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try looping on item table and update the values from header table by read statement.&lt;/P&gt;&lt;P&gt;Even if there are multiple line items in item table, all line items will get updated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2008 14:15:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675112#M885053</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-09T14:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675113#M885054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you need a loop inside another loop then you should use either&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a sorted table for the inner table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or if you need the standard table, then  read binary search, loop from index  if ( condition not fulfilled ) exit endif.&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;   see last section of  &lt;/P&gt;&lt;P&gt;Measurements on internal tables: Reads and Loops:&lt;/P&gt;&lt;P&gt;/people/siegfried.boes/blog/2007/09/12/runtimes-of-reads-and-loops-on-internal-tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would not recommend parallel cursor, the real fault tolerant solution is much more complicated then the reference above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2008 07:55:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675113#M885054</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-10T07:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675114#M885055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks every body&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Apr 2008 11:44:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675114#M885055</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-14T11:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: removing loop from loop.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675115#M885056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;             Performance Tuning using parallel cursor&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Extracts from program ZFAL2002&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;************************************************************************&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;START-OF-SELECTION&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SELECT *&lt;/P&gt;&lt;P&gt;  INTO TABLE I_KEPH FROM KEPH&lt;/P&gt;&lt;P&gt;  WHERE KADKY &amp;lt;= SY-DATUM&lt;/P&gt;&lt;P&gt;    AND TVERS = '01'&lt;/P&gt;&lt;P&gt;    AND KALKA IN ('01','Z1','Z2')&lt;/P&gt;&lt;P&gt;    AND BWVAR IN ('Z01','Z02','Z03','Z04','Z07')&lt;/P&gt;&lt;P&gt;    AND KKZST = ' '&lt;/P&gt;&lt;P&gt;    AND KKZMA = ' '&lt;/P&gt;&lt;P&gt;    AND KKZMM = ' '&lt;/P&gt;&lt;P&gt;    AND KEART = 'H'&lt;/P&gt;&lt;P&gt;    AND PATNR = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Table must be sorted to ensure all required records are together&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  SORT I_KEPH BY KALNR KALKA BWVAR KADKY.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Perform actual processing&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  Perform get_cost_values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM GET_COST_VALUES.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Determine start position and then process all records for given key&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;from that starting point&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;i_keph is sorted on kalnr kalka bwvar kadky.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  READ TABLE I_KEPH WITH KEY KALNR = W_KEKO-KALNR&lt;/P&gt;&lt;P&gt;                             KALKA = W_KEKO-KALKA&lt;/P&gt;&lt;P&gt;                             BWVAR = W_KEKO-BWVAR&lt;/P&gt;&lt;P&gt;                             KADKY = W_KEKO-KADKY BINARY SEARCH.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Loop at itab from first record found (sy-tabix) until record&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;no-longer matches your criteria.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    LOOP AT I_KEPH FROM SY-TABIX.&lt;/P&gt;&lt;P&gt;      IF  I_KEPH-KALNR = W_KEKO-KALNR AND I_KEPH-KALKA = W_KEKO-KALKA&lt;/P&gt;&lt;P&gt;      AND I_KEPH-BWVAR = W_KEKO-BWVAR AND I_KEPH-KADKY = W_KEKO-KADKY.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Key match&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        D_MAT_COST = D_MAT_COST + I_KEPH-KST001.&lt;/P&gt;&lt;P&gt;        D_LAB_COST = D_LAB_COST + I_KEPH-KST004.&lt;/P&gt;&lt;P&gt;        D_OVER_HEAD = D_OVER_HEAD + I_KEPH-KST010.&lt;/P&gt;&lt;P&gt;        D_EXT_PURCH = D_EXT_PURCH + I_KEPH-KST014.&lt;/P&gt;&lt;P&gt;        D_MISC_COST = D_MISC_COST + I_KEPH-KST002 + I_KEPH-KST003&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST005 + I_KEPH-KST006 + I_KEPH-KST007&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST008 + I_KEPH-KST009 + I_KEPH-KST011&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST012 + I_KEPH-KST013 + I_KEPH-KST015&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST016 + I_KEPH-KST017 + I_KEPH-KST018&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST019 + I_KEPH-KST020 + I_KEPH-KST021&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST022 + I_KEPH-KST023 + I_KEPH-KST024&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST025 + I_KEPH-KST026 + I_KEPH-KST027&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST028 + I_KEPH-KST029 + I_KEPH-KST030&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST031 + I_KEPH-KST032 + I_KEPH-KST033&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST034 + I_KEPH-KST035 + I_KEPH-KST036&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST037 + I_KEPH-KST038 + I_KEPH-KST039&lt;/P&gt;&lt;P&gt;                    + I_KEPH-KST040.&lt;/P&gt;&lt;P&gt;      ELSE.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Key greater - can't be less&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        EXIT.                                               " Exit loop&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  D_MAT_COST  = D_MAT_COST  / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_LAB_COST  = D_LAB_COST  / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_OVER_HEAD = D_OVER_HEAD / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_EXT_PURCH = D_EXT_PURCH / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;  D_MISC_COST = D_MISC_COST / W_KEKO-LOSGR.&lt;/P&gt;&lt;P&gt;ENDFORM.                               " GET_COST_VALUES&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Apr 2008 04:52:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/removing-loop-from-loop/m-p/3675115#M885056</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-04-15T04:52:39Z</dc:date>
    </item>
  </channel>
</rss>

