<?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 AT END OF in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771795#M1306675</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort ur internal with matkl and date.&lt;/P&gt;&lt;P&gt;your problem might get solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Jul 2009 13:40:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-07-06T13:40:04Z</dc:date>
    <item>
      <title>Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771794#M1306674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;I'm having a weird problem with the END OF option of the AT statement. I already knew that it can get tricky because it compares not only the specified field's content after AT END OF, but also all the fields to its left, in the structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this still doesn't answer why am I getting very weird results here.&lt;/P&gt;&lt;P&gt;Basically, this is my scenario:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My internal table:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATKL              COLUMN B                   COLUMN C&lt;/P&gt;&lt;P&gt;140                    xxxxxx                        yyyyyyy&lt;/P&gt;&lt;P&gt;140                    cfsdd                           dasdsa&lt;/P&gt;&lt;P&gt;140                   pdasd                          oasdas&lt;/P&gt;&lt;P&gt;150                   dsadas                         dasdas&lt;/P&gt;&lt;P&gt;150                   asdasd                         asdasd&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;170                   xxxx                             xxxx&lt;/P&gt;&lt;P&gt;170                   xxx                               xxxx&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;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The code I'm having problems with is:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT my_tab INTO my_struct WHERE date &amp;lt;= p_date.
    ....code
    ....code

    AT END OF matkl .
      CLEAR ls_t023t.
      READ TABLE gt_t023t INTO ls_t023t WITH KEY matkl = my_struct-matkl spras = sy-langu.
      ls_alv_rep-wgbez = ls_t023t-wgbez.
      APPEND ls_alv_rep TO gt_alv_rep.
      CLEAR ls_alv_rep.
    ENDAT.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;The table is, of course, sorted by MATKL, and there are no fields left to MATKL.&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;For some reason, the code within the END OF is only being triggered for a small set of the MATKLs from my table. &lt;U&gt;Of course, I'm taking into account the WHERE clause in the LOOP statement&lt;/U&gt;, but what I'm saying is that once the code enters the loop, I'd expect that each MATKL the loop processes, eventually enters the END OF code, after the last line for the given MATKL value. But what's happening is that, say I have 10 different MATKLs in my table, and all of them enter the code within the LOOP, only some of them reach the END OF code - the rest simply stops in the AT END OF line, then skips right away to ENDLOOP, continuing with the next line of the table (debugging).&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;There is no header line, no TABLES statement declared... this is a STANDARD TABLE&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone has any idea of what I'm missing here ?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Avraham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 13:36:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771794#M1306674</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-06T13:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771795#M1306675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort ur internal with matkl and date.&lt;/P&gt;&lt;P&gt;your problem might get solved&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 13:40:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771795#M1306675</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-06T13:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771796#M1306676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just to troubleshoot, I would remove the WHERE clause in the LOOP statement to see if that fixes your issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you stated, AT statements are tricky enough, but you've introduced another layer of complexity with the WHERE clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you may want to remove the AT END OF completely and simply check the old &amp;amp; new MATKL values manually - then trigger your code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if old_matkl &amp;lt;&amp;gt; new_matkl.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jul 2009 22:25:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771796#M1306676</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-06T22:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771797#M1306677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;sort first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2009 00:29:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771797#M1306677</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-07T00:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771798#M1306678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Avraham Kahana ,&lt;/P&gt;&lt;P&gt;&amp;lt;li&amp;gt;SORT internal table by MATKL before you use AT END events within LOOP-ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Venkat.O&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2009 02:48:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771798#M1306678</guid>
      <dc:creator>venkat_o</dc:creator>
      <dc:date>2009-07-07T02:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with AT END OF</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771799#M1306679</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;The reason for your problem is as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;assume your internal table (I_DATA)&lt;/P&gt;&lt;P&gt;values as follows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MATKL DATE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yours values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;140     12/12/2008&lt;/P&gt;&lt;P&gt;140     13/12/2008&lt;/P&gt;&lt;P&gt;140     14/12/2008&lt;/P&gt;&lt;P&gt;150     12/12/2008&lt;/P&gt;&lt;P&gt;150     13/12/2008&lt;/P&gt;&lt;P&gt;160     12/12/2008&lt;/P&gt;&lt;P&gt;160     13/12/2008&lt;/P&gt;&lt;P&gt;160     14/12/2008&lt;/P&gt;&lt;P&gt;170     12/12/2008&lt;/P&gt;&lt;P&gt;170     13/12/2008&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If your loop is like the below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at i_data where date &amp;lt;= 13/12/2008.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The loop will not go to the last entry for MATKL "140" and "160" ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; so the AT END OF MATKL will trigger for the MATKL "150" and "170".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Smart Varghese&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2009 05:54:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-at-end-of/m-p/5771799#M1306679</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-07T05:54:24Z</dc:date>
    </item>
  </channel>
</rss>

