<?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 on loop with where condition... in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598745#M268849</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    problem is that you should not check &lt;/P&gt;&lt;P&gt;     sy-subrc in loop .it will be useful to &lt;/P&gt;&lt;P&gt;     check subrc value for read table syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    remove statements marked in bold    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT it_bsis_bsas ASSIGNING &amp;lt;fs_dum&amp;gt;&lt;/P&gt;&lt;P&gt;WHERE hkont = wa_summary-hkont&lt;/P&gt;&lt;P&gt;AND year_dum = wa_summary-year_dum&lt;/P&gt;&lt;P&gt;AND waers = wa_summary-waers.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;IF sy-subrc = 0.&amp;lt;/b&amp;gt;ADD &amp;lt;fs_dum&amp;gt;-wrbtr TO wa_summary-wrbtr.&lt;/P&gt;&lt;P&gt;ADD &amp;lt;fs_dum&amp;gt;-dmbtr TO wa_summary-dmbtr.&lt;/P&gt;&lt;P&gt;IF NOT wa_exch-exch_rate IS INITIAL.&lt;/P&gt;&lt;P&gt;IF &amp;lt;fs_dum&amp;gt;-waers = 'PHP'.&lt;/P&gt;&lt;P&gt;lv_balance = 1 / wa_exch-exch_rate * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * lv_balance.&lt;/P&gt;&lt;P&gt;ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ELSE.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ENDIF.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CLEAR lv_balance.&lt;/P&gt;&lt;P&gt;DELETE it_bsis_bsas.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;IF NOT wa_summary-column1 IS INITIAL.&lt;/P&gt;&lt;P&gt;APPEND wa_summary TO it_summary.&lt;/P&gt;&lt;P&gt;CLEAR wa_summary.&lt;/P&gt;&lt;P&gt;ENDIF.&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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;amole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Oct 2006 10:19:10 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-10-02T10:19:10Z</dc:date>
    <item>
      <title>Problem on loop with where condition...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598741#M268845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello experts, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering on why my loop statement with a where clause does not work on&lt;/P&gt;&lt;P&gt;some conditions but when I check on the table(it_bsis_bsas) it has those records that&lt;/P&gt;&lt;P&gt;is mentioned in the where clause. For example, wa_summary-hkont has a value of 1234567890 &lt;/P&gt;&lt;P&gt;and wa_summary-year_dum has a value of 1999 and wa_summary-waers has a value of 'PHP'. I know&lt;/P&gt;&lt;P&gt;there are records which will satisfy it since I checked my internal table. The weird thing is&lt;/P&gt;&lt;P&gt;that it works on some records which also satisfies those conditions. The loop must always work&lt;/P&gt;&lt;P&gt;or meaning to say must always have a value of '0' in sy-subrc.&lt;/P&gt;&lt;P&gt;Anyway, below is my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: lv_balance TYPE bsis-wrbtr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    FIELD-SYMBOLS: &amp;lt;fs_dum&amp;gt; LIKE LINE OF it_bsis_bsas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    it_bsis_bsas[] = im_bsis_bsas[].&lt;/P&gt;&lt;P&gt;    it_exch[]      = im_exch[].&lt;/P&gt;&lt;P&gt;    CLEAR wa_exch.&lt;/P&gt;&lt;P&gt;    SORT it_bsis_bsas BY hkont year_dum DESCENDING waers.&lt;/P&gt;&lt;P&gt;    LOOP AT it_bsis_bsas ASSIGNING &amp;lt;fs_bsis_bsas&amp;gt;.&lt;/P&gt;&lt;P&gt;      AT NEW hkont.&lt;/P&gt;&lt;P&gt;        MOVE &amp;lt;fs_bsis_bsas&amp;gt;-hkont TO wa_summary-hkont.&lt;/P&gt;&lt;P&gt;      ENDAT.&lt;/P&gt;&lt;P&gt;      AT NEW year_dum.&lt;/P&gt;&lt;P&gt;        MOVE &amp;lt;fs_bsis_bsas&amp;gt;-year_dum TO wa_summary-year_dum.&lt;/P&gt;&lt;P&gt;      ENDAT.&lt;/P&gt;&lt;P&gt;      AT NEW waers.&lt;/P&gt;&lt;P&gt;        MOVE &amp;lt;fs_bsis_bsas&amp;gt;-waers TO wa_summary-waers.&lt;/P&gt;&lt;P&gt;        t_from_curr = wa_summary-waers.&lt;/P&gt;&lt;P&gt;        READ TABLE it_exch WITH KEY year      = wa_summary-year_dum&lt;/P&gt;&lt;P&gt;                                    rate      = t_rate_type&lt;/P&gt;&lt;P&gt;                                    from_curr = t_from_curr&lt;/P&gt;&lt;P&gt;                                    INTO wa_exch TRANSPORTING exch_rate.&lt;/P&gt;&lt;P&gt;        IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;          MOVE wa_exch-exch_rate TO wa_summary-rate.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDAT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT it_bsis_bsas ASSIGNING &amp;lt;fs_dum&amp;gt;&lt;/P&gt;&lt;P&gt;         WHERE hkont    = wa_summary-hkont&lt;/P&gt;&lt;P&gt;           AND year_dum = wa_summary-year_dum&lt;/P&gt;&lt;P&gt;           AND waers    = wa_summary-waers.&lt;/P&gt;&lt;P&gt;        IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;          ADD &amp;lt;fs_dum&amp;gt;-wrbtr TO wa_summary-wrbtr.&lt;/P&gt;&lt;P&gt;          ADD &amp;lt;fs_dum&amp;gt;-dmbtr TO wa_summary-dmbtr.&lt;/P&gt;&lt;P&gt;          IF NOT wa_exch-exch_rate IS INITIAL.&lt;/P&gt;&lt;P&gt;            IF &amp;lt;fs_dum&amp;gt;-waers = 'PHP'.&lt;/P&gt;&lt;P&gt;              lv_balance = 1 / wa_exch-exch_rate * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;              lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * lv_balance.&lt;/P&gt;&lt;P&gt;              ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;            ELSE.&lt;/P&gt;&lt;P&gt;              lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;              ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;            ENDIF.&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;          CLEAR lv_balance.&lt;/P&gt;&lt;P&gt;          DELETE it_bsis_bsas.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;      IF NOT wa_summary-column1 IS INITIAL.&lt;/P&gt;&lt;P&gt;        APPEND wa_summary TO it_summary.&lt;/P&gt;&lt;P&gt;        CLEAR wa_summary.&lt;/P&gt;&lt;P&gt;      ENDIF.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot guys and take care!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: viraylab&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Oct 2006 09:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598741#M268845</guid>
      <dc:creator>aris_hidalgo</dc:creator>
      <dc:date>2006-10-02T09:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem on loop with where condition...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598742#M268846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To be honest, it is not advisable to use nested loop for the same internal table. It would better if you copy the table into another one and loop at the copy with the where condition. It would surely work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Oct 2006 09:33:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598742#M268846</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-02T09:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Problem on loop with where condition...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598743#M268847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Why are you checking SY-SUBRC immediately after entering the LOOP? this makes no sense at all:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_bsis_bsas ASSIGNING &amp;lt;fs_dum&amp;gt;&lt;/P&gt;&lt;P&gt;WHERE hkont = wa_summary-hkont&lt;/P&gt;&lt;P&gt;AND year_dum = wa_summary-year_dum&lt;/P&gt;&lt;P&gt;AND waers = wa_summary-waers.&lt;/P&gt;&lt;P&gt;  IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    ADD &amp;lt;fs_dum&amp;gt;-wrbtr TO wa_summary-wrbtr.&lt;/P&gt;&lt;P&gt;    ADD &amp;lt;fs_dum&amp;gt;-dmbtr TO wa_summary-dmbtr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your logic is flawed. The very fact that you have entered the loop means a matching record has been found there is no need to check sy-subrc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If no record is found sy-subrc = 4 immediately after the loop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Oct 2006 09:49:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598743#M268847</guid>
      <dc:creator>former_member378318</dc:creator>
      <dc:date>2006-10-02T09:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem on loop with where condition...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598744#M268848</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;If you know that only one record would be read, I would use read table and test in sy-tabix or sy-subr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eddy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS. &lt;/P&gt;&lt;P&gt;Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points. &lt;/P&gt;&lt;P&gt;Spread the wor(l)d!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Oct 2006 10:02:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598744#M268848</guid>
      <dc:creator>eddy_declercq</dc:creator>
      <dc:date>2006-10-02T10:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Problem on loop with where condition...</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598745#M268849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;    problem is that you should not check &lt;/P&gt;&lt;P&gt;     sy-subrc in loop .it will be useful to &lt;/P&gt;&lt;P&gt;     check subrc value for read table syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    remove statements marked in bold    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT it_bsis_bsas ASSIGNING &amp;lt;fs_dum&amp;gt;&lt;/P&gt;&lt;P&gt;WHERE hkont = wa_summary-hkont&lt;/P&gt;&lt;P&gt;AND year_dum = wa_summary-year_dum&lt;/P&gt;&lt;P&gt;AND waers = wa_summary-waers.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;IF sy-subrc = 0.&amp;lt;/b&amp;gt;ADD &amp;lt;fs_dum&amp;gt;-wrbtr TO wa_summary-wrbtr.&lt;/P&gt;&lt;P&gt;ADD &amp;lt;fs_dum&amp;gt;-dmbtr TO wa_summary-dmbtr.&lt;/P&gt;&lt;P&gt;IF NOT wa_exch-exch_rate IS INITIAL.&lt;/P&gt;&lt;P&gt;IF &amp;lt;fs_dum&amp;gt;-waers = 'PHP'.&lt;/P&gt;&lt;P&gt;lv_balance = 1 / wa_exch-exch_rate * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * lv_balance.&lt;/P&gt;&lt;P&gt;ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ELSE.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;lv_balance = &amp;lt;fs_dum&amp;gt;-wrbtr * wa_exch-exch_rate.&lt;/P&gt;&lt;P&gt;ADD lv_balance TO wa_summary-column1.&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;ENDIF.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CLEAR lv_balance.&lt;/P&gt;&lt;P&gt;DELETE it_bsis_bsas.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;IF NOT wa_summary-column1 IS INITIAL.&lt;/P&gt;&lt;P&gt;APPEND wa_summary TO it_summary.&lt;/P&gt;&lt;P&gt;CLEAR wa_summary.&lt;/P&gt;&lt;P&gt;ENDIF.&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;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;amole&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Oct 2006 10:19:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-on-loop-with-where-condition/m-p/1598745#M268849</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-10-02T10:19:10Z</dc:date>
    </item>
  </channel>
</rss>

