<?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: how to group data based on date in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540184#M1751813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure if I understood your question correctly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I have understood, you can use the following logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This logic will move all the records from lt_fields2 to another table lt_fields1 with begda between 20 and 30 of any month, except for the first record. It will also move records for every date between begda and endda of each record. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can alter the logic based on your exact requirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare another table lt_fields1 like lt_fields2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data del_flag. &lt;/P&gt;&lt;P&gt;data prev_month(2) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_fields by pernr begda. &lt;/P&gt;&lt;P&gt;clear del_flag. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_fields2 into wa_fields where begda+6(2) GE 20. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* Delete the first record having date greater than 20 in a month for each pernr. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; at new pernr. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear del_flag. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endat. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if begda+4(2) NE prev_month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear del_flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp; endif.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if del_flag is initial.&amp;nbsp; &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del_flag = 'X'.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue.&amp;nbsp; " This record will not be moved to the final internal table. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* Add records for each date between begda and endda. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; append wa_fields to lt_fields1. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; prev_month = begda+4(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while wa_fields-begda LT wa_fields-endda. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wa_fields-begda = wa_fields-begda+1. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; append wa_fields to lt_fields1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endwhile. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; endloop. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Jul 2013 07:17:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-07-01T07:17:04Z</dc:date>
    <item>
      <title>how to group data based on date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540181#M1751810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In my program the internal table is returning several values based on date.&lt;/P&gt;&lt;P&gt;for example for the first pernr in the image below&amp;nbsp; there are four records. i need to delete the first record which is between the dates 20 and 30 .&lt;/P&gt;&lt;P&gt;and also i need to get the difference between the dates as the record 23 and 28&amp;nbsp; i need to get separate dates as 24, 25..28.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/238906" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 04:31:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540181#M1751810</guid>
      <dc:creator>former_member812619</dc:creator>
      <dc:date>2013-07-01T04:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to group data based on date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540182#M1751811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Narasimha,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since the date fields BEGDA and ENDDA are stored in char field of format &lt;EM&gt;YYYYMMDD&lt;/EM&gt;, the month and day can be extracted as sub-strings. &lt;/P&gt;&lt;P&gt;So, modify your internal table structure lt_fields2 and add two new fields to assign the month and day: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;lt_fields2-month = BEGDA+4(2) &lt;/SPAN&gt;and &lt;SPAN style="font-family: 'courier new', courier;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;lt_fields2-day = BEGDA+6(2).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Now you can put the sorting condition on it as: &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;SORT lt_fields2 BY month day.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;To delete the records between the dates 20 and 30:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;DELETE lt_fields2 WHERE day BETWEEN 20 AND 30.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rgds&lt;/P&gt;&lt;P&gt;&lt;EM&gt;~Kaushalya&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 06:41:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540182#M1751811</guid>
      <dc:creator>kaushalya</dc:creator>
      <dc:date>2013-07-01T06:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to group data based on date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540183#M1751812</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;Share the code that you tried and where it is going wrong. We will correct it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Swarna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 06:55:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540183#M1751812</guid>
      <dc:creator>former_member217544</dc:creator>
      <dc:date>2013-07-01T06:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to group data based on date</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540184#M1751813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure if I understood your question correctly. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From what I have understood, you can use the following logic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This logic will move all the records from lt_fields2 to another table lt_fields1 with begda between 20 and 30 of any month, except for the first record. It will also move records for every date between begda and endda of each record. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can alter the logic based on your exact requirement. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;declare another table lt_fields1 like lt_fields2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data del_flag. &lt;/P&gt;&lt;P&gt;data prev_month(2) type c.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sort lt_fields by pernr begda. &lt;/P&gt;&lt;P&gt;clear del_flag. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at lt_fields2 into wa_fields where begda+6(2) GE 20. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* Delete the first record having date greater than 20 in a month for each pernr. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; at new pernr. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear del_flag. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endat. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if begda+4(2) NE prev_month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; clear del_flag.&lt;/P&gt;&lt;P&gt;&amp;nbsp; endif.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if del_flag is initial.&amp;nbsp; &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del_flag = 'X'.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue.&amp;nbsp; " This record will not be moved to the final internal table. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endif. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* Add records for each date between begda and endda. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; append wa_fields to lt_fields1. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; prev_month = begda+4(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while wa_fields-begda LT wa_fields-endda. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; wa_fields-begda = wa_fields-begda+1. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; append wa_fields to lt_fields1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; endwhile. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; endloop. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 07:17:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-group-data-based-on-date/m-p/9540184#M1751813</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-07-01T07:17:04Z</dc:date>
    </item>
  </channel>
</rss>

