<?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: Problem with nested Loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755487#M903471</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;I think you should a flag to check the process in each for loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thats all..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 May 2008 14:07:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-06T14:07:16Z</dc:date>
    <item>
      <title>Problem with nested Loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755486#M903470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i ve problem in nested loop.  my peace of code is below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   CLEAR: it_prps, it_final, wa_final, wa_it_prps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  LOOP AT it_prps.     &lt;/P&gt;&lt;P&gt;    CASE month.&lt;/P&gt;&lt;P&gt;      WHEN '08'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt; ACTUAL BILLING&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        LOOP AT it_final INTO wa_final&lt;/P&gt;&lt;P&gt;         WHERE posid = it_prps-posid&lt;/P&gt;&lt;P&gt;            AND wrttp = c_04&lt;/P&gt;&lt;P&gt;            AND beltp = c_02&lt;/P&gt;&lt;P&gt;            AND versn = c_0&lt;/P&gt;&lt;P&gt;            AND ( vorga = c_coin OR vorga = c_rku2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          CLEAR act_billing.&lt;/P&gt;&lt;P&gt;          IF sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;            MOVE wa_final-wlp08 TO t_act_billing.&lt;/P&gt;&lt;P&gt;            act_billing = act_billing + t_act_billing.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         CLEAR: it_prps, it_final.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;            CLEAR: wa_final.&lt;/P&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt; PLANNED REVENUE&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        LOOP AT it_final INTO wa_final&lt;/P&gt;&lt;P&gt;                         WHERE posid = it_prps-posid&lt;/P&gt;&lt;P&gt;                         AND wrttp = c_01&lt;/P&gt;&lt;P&gt;                         AND beltp = c_02&lt;/P&gt;&lt;P&gt;                         AND versn = c_0&lt;/P&gt;&lt;P&gt;                         AND ( vorga = c_sdor OR vorga = c_rkp5 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          CLEAR plan_rev.&lt;/P&gt;&lt;P&gt;          IF sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;            MOVE wa_final-wlp08 TO t_plan_rev.&lt;/P&gt;&lt;P&gt;            plan_rev = plan_rev + t_plan_rev.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;         CLEAR: it_prps, it_final.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="3" type="ul"&gt;&lt;P&gt;PLANNED COST&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;        LOOP AT it_final INTO wa_final&lt;/P&gt;&lt;P&gt;                         WHERE posid = it_prps-posid&lt;/P&gt;&lt;P&gt;                         AND wrttp = c_01&lt;/P&gt;&lt;P&gt;                         AND versn = c_0&lt;/P&gt;&lt;P&gt;                         AND beltp = c_1.&lt;/P&gt;&lt;P&gt;          CLEAR plan_cost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          IF sy-subrc IS INITIAL.&lt;/P&gt;&lt;P&gt;            MOVE wa_final-wlp08 TO t_plan_cost.&lt;/P&gt;&lt;P&gt;            plan_cost = plan_cost + t_plan_cost.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;           CLEAR: wa_final.&lt;/P&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;P&gt;     ENDCASE.&lt;/P&gt;&lt;P&gt;   ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; In the above code am trying to find 3values like Actual Billing, Planned Revenue and Planed cost.&lt;/P&gt;&lt;P&gt; Under the main loop Loop at it_prps.  here am looping the table it_final 3times for finding 3values.&lt;/P&gt;&lt;P&gt;but the problem is if i comment for below 2 loops, then First loop is doing well. but if i open for 3 loops&lt;/P&gt;&lt;P&gt;now supose if First loop fails then control is come out of main loop( it_prps ), it is going to 2nd and 3rd loops. and its giving zero values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Could anyone tell me where i gone rong, how control will come to 2nd loop if 1st loop fails.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;Thanks in Advance,&lt;/P&gt;&lt;P&gt;sudharsan.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: SUDHARSAN RAO on May 6, 2008 3:39 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2008 13:38:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755486#M903470</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-06T13:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with nested Loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755487#M903471</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;I think you should a flag to check the process in each for loops.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thats all..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2008 14:07:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755487#M903471</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-06T14:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with nested Loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755488#M903472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Number of issues with this code.&lt;/P&gt;&lt;P&gt;First.. how is it_final defined.  With a header? or standard table of wa_final?&lt;/P&gt;&lt;P&gt;If like the 2nd  (standard table of wa_final) then this line will clear the table.    CLEAR: it_prps, it_final.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In each of your internal loops that have the pattern like this&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
      LOOP AT it_final INTO wa_final
      WHERE posid = it_prps-posid
      AND wrttp = c_04
      AND beltp = c_02
      AND versn = c_0
      AND ( vorga = c_coin OR vorga = c_rku2 ).

        CLEAR act_billing.
        IF sy-subrc IS INITIAL.
          MOVE wa_final-wlp08 TO t_act_billing.
          act_billing = act_billing + t_act_billing.
        ENDIF.

        CLEAR: it_prps, it_final.
        CLEAR: wa_final.
      ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Should be recoded to look like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
      CLEAR act_billing.    "&amp;lt;== Moved
      LOOP AT it_final INTO wa_final
      WHERE posid = it_prps-posid
      AND wrttp = c_04
      AND beltp = c_02
      AND versn = c_0
      AND ( vorga = c_coin OR vorga = c_rku2 ).

**        IF sy-subrc IS INITIAL.   " Don't Need this.. will only come in here if record found
          MOVE wa_final-wlp08 TO t_act_billing.
          act_billing = act_billing + t_act_billing.
**        ENDIF.      " Matches the IF

**        CLEAR: it_prps, it_final.   " Shouldn't need this
 **       CLEAR: wa_final.            " Shouldn't need this
      ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2008 14:19:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755488#M903472</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-06T14:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with nested Loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755489#M903473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sudarshan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  Check the below code....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_prps. &lt;/P&gt;&lt;P&gt;CASE month.&lt;/P&gt;&lt;P&gt;WHEN '08'.&lt;/P&gt;&lt;P&gt;LOOP AT it_final INTO wa_final&lt;/P&gt;&lt;P&gt;posid = it_prps-posid.&lt;/P&gt;&lt;P&gt;IF wrttp = c_04&lt;/P&gt;&lt;P&gt;AND beltp = c_02&lt;/P&gt;&lt;P&gt;AND versn = c_0&lt;/P&gt;&lt;P&gt;AND ( vorga = c_coin OR vorga = c_rku2 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Do the process for ACTUAL BILLING &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF wrttp = c_01&lt;/P&gt;&lt;P&gt;AND beltp = c_02&lt;/P&gt;&lt;P&gt;AND versn = c_0&lt;/P&gt;&lt;P&gt;AND ( vorga = c_sdor OR vorga = c_rkp5 ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Do the process for PLANNED REVENUE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF wrttp = c_01&lt;/P&gt;&lt;P&gt;AND versn = c_0&lt;/P&gt;&lt;P&gt;AND beltp = c_1.&lt;/P&gt;&lt;P&gt;CLEAR plan_cost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Do the process for PLANNED COST &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLEAR: it_prps, it_final. &lt;/P&gt;&lt;P&gt;CLEAR: wa_final.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Bujji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2008 14:26:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-nested-loop/m-p/3755489#M903473</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-06T14:26:14Z</dc:date>
    </item>
  </channel>
</rss>

