<?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: doubt in loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426017#M1245130</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;Your complete logic is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See in the second loop itself you are again and again assigning values to wa_final structure so it will take only the last value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and at the end you are Appending the wa_final's value to the internal table, that is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz varify your logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Apr 2009 10:46:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-04-09T10:46:40Z</dc:date>
    <item>
      <title>doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426016#M1245129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gurus...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have my code below ...problem is that when it goes for the first time if get the &lt;/P&gt;&lt;P&gt;value but when it goes again in to the loop , first loop is getting exected &lt;/P&gt;&lt;P&gt;the second and the third loop returns sy-subrc 4 thou it has value.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;iam not able to find it out y????can you plzzz helppp???&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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code of loop&lt;/P&gt;&lt;P&gt;===============&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_pos INTO wa_pos .
  READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto .
  IF sy-subrc = 0.

     wa_final-name1 = wa_kna1-name1.
     wa_final-xblnr = wa_pos-xblnr.

    read table it_t005u into wa_t005u with key  bland = wa_kna1-regio.
    If sy-subrc = 0.
      wa_final-bezei = wa_t005u-bezei.
     Endif.
  Endif.

 Loop at it_vbrp into wa_vbrp  where vbeln = wa_bkpf-vbeln.
    read table it_vbrk into wa_vbrk with key vbeln = wa_vbrp-vbeln.
    If sy-subrc = 0.
      wa_final-knumv = wa_vbrk-knumv.
    Endif.

    wa_final-arktx = wa_vbrp-arktx.
    wa_Final-fkimg = wa_vbrp-fkimg.

    move wa_final-arktx to wa_final-a.
    move wa_final-fkimg to wa_final-b.

    qty = wa_vbrp-fkimg.
    split qty at '.' into text2 text3.
    move text2 to wa_final-b.

    concatenate wa_Final-a '-' wa_final-b into wa_final-c separated by space.


    wa_final-name1 = wa_kna1-name1.
    wa_final-xblnr = wa_pos-xblnr.

    Loop at it_konv into wa_konv where knumv = wa_vbrk-knumv and  kposn = wa_vbrp-posnr.

      wa_pos-dmshb = ( wa_konv-kwert ) - ( ( wa_konv-kwert * ra_data ) / 100 ).
      wa_final-dmbtr = wa_pos-dmshb.

    Endloop.


  Endloop.
  Append wa_final to it_final
  clear: wa_bkpf, wa_kna1, wa_t005u,wa_vbrk, wa_vbrp, wa_konv, wa_final, wa_pos.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Apr 9, 2009 1:20 PM - added  tags&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 10:32:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426016#M1245129</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T10:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426017#M1245130</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;Your complete logic is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See in the second loop itself you are again and again assigning values to wa_final structure so it will take only the last value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and at the end you are Appending the wa_final's value to the internal table, that is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;plz varify your logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 10:46:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426017#M1245130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T10:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426018#M1245131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Position of your append is wrong ...&lt;/P&gt;&lt;P&gt;it should be above all the endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT it_pos INTO wa_pos .
  *** logic ***
  READ TABLE it_kna1 INTO wa_kna1 WITH KEY kunnr = wa_pos-konto .
  *** logic ***
  read table it_t005u into wa_t005u with key bland = wa_kna1-regio.
  *** logic ***
  Loop at it_vbrp into wa_vbrp where vbeln = wa_bkpf-vbeln.
    *** logic ***
    read table it_vbrk into wa_vbrk with key vbeln = wa_vbrp-vbeln.
    *** logic ***
    Loop at it_konv into wa_konv where knumv = wa_vbrk-knumv and kposn = wa_vbrp-posnr.
      *** logic ***
      Append wa_final to it_final "Check position of this statement.
    Endloop.
  Endloop.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lalit Mohan Gupta.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Lalit Mohan Gupta on Apr 9, 2009 4:45 PM -  Written the skeleton of code. Label Edited&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 10:58:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426018#M1245131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T10:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426019#M1245132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the reply ...but the logic is not wrong....since again i want the same datas for the line item in the second loop i have used the first loops  final field again in second thats it and in third loop i am making the calculations thats it&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 11:00:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426019#M1245132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T11:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426020#M1245133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Beginer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the 2nd loop, where is the value of wa_bkpf-vbeln coming from, Just keep a break point before the second loop and before the 3rd loop, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Kumar M.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 11:06:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426020#M1245133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T11:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426021#M1245134</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;In the second loop, check the value of wa_bkpf-vbeln(either present or not) and also whether it is present in the internal table it_vbrp or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nihar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 11:11:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426021#M1245134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T11:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426022#M1245135</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;As already mentioned by the other  guys above, your append statement is not correct. It should have been before the endloop for VBRP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 11:48:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426022#M1245135</guid>
      <dc:creator>dev_parbutteea</dc:creator>
      <dc:date>2009-04-09T11:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426023#M1245136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Beginer,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the way u have appended the Final internal table is not right...in this case u will never get the first line item of the 2nd Loop...but u will keep getting the last line item of vbrk and vbrp. Same is the case for the 3rd Loop. I don't know how this satisfies your requirement. and about the sy-subrc values for 2nd and 3rd loop...there may be any kind of error....may be the internal tables it_vbrp, it_vbrk, it_konv are initial...or may be the Read statement has failed as there were no matching entries ......and so on. Just put a break point at the start of the 1st Loop and debug. I think that will help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 12:42:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426023#M1245136</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T12:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: doubt in loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426024#M1245137</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;In your source code you are clearing the content of wa_bkpf after your first loop step and wa_bkpf-vbeln is the criteria that makes you enter the second loop. &lt;/P&gt;&lt;P&gt;That explains why you are getting a subrc = 4 issue for next loop steps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOOP AT it_pos INTO wa_pos .&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;.............&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;............&lt;/EM&gt; &lt;/P&gt;&lt;P&gt; &lt;EM&gt;Loop at it_vbrp into wa_vbrp  &lt;STRONG&gt;where vbeln = wa_bkpf-vbeln&lt;/STRONG&gt;.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;............&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;Endloop.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;EM&gt;Append wa_final to it_final&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;  &lt;STRONG&gt;+clear: wa_bkpf,&lt;/STRONG&gt; wa_kna1, wa_t005u,wa_vbrk, wa_vbrp, wa_konv, wa_final, wa_pos.+&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ENDLOOP.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way you manage your "loops" may lead to performance issues. You could find a better solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2009 13:08:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-loop/m-p/5426024#M1245137</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-04-09T13:08:05Z</dc:date>
    </item>
  </channel>
</rss>

