<?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 Fetching data for las 12 Months in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756740#M327823</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are having one custom table where fields are customer no, material no, year, month, quantity1.&lt;/P&gt;&lt;P&gt;Now I want to create a report which on entering customer no &amp;amp; material no in input should add up the values for last 12 months from the current date and display as one value. &lt;/P&gt;&lt;P&gt;Example of entries in database:&lt;/P&gt;&lt;P&gt;custmr no   matrl no.   year   month  qty1&lt;/P&gt;&lt;P&gt;1                   1           2006    01       45.00&lt;/P&gt;&lt;P&gt;1                   1           2006    02       25.00&lt;/P&gt;&lt;P&gt;1                   2           2006    01       10.00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After executing the report I want the result as&lt;/P&gt;&lt;P&gt;custmr no   matrl no.   year     qty1&lt;/P&gt;&lt;P&gt;1                   1           2006    70.00&lt;/P&gt;&lt;P&gt;1                   2           2006    10.00&lt;/P&gt;&lt;P&gt;and this addition should be done for last 12 months from the current date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Nishu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Dec 2006 13:07:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-12-21T13:07:44Z</dc:date>
    <item>
      <title>Fetching data for las 12 Months</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756740#M327823</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We are having one custom table where fields are customer no, material no, year, month, quantity1.&lt;/P&gt;&lt;P&gt;Now I want to create a report which on entering customer no &amp;amp; material no in input should add up the values for last 12 months from the current date and display as one value. &lt;/P&gt;&lt;P&gt;Example of entries in database:&lt;/P&gt;&lt;P&gt;custmr no   matrl no.   year   month  qty1&lt;/P&gt;&lt;P&gt;1                   1           2006    01       45.00&lt;/P&gt;&lt;P&gt;1                   1           2006    02       25.00&lt;/P&gt;&lt;P&gt;1                   2           2006    01       10.00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After executing the report I want the result as&lt;/P&gt;&lt;P&gt;custmr no   matrl no.   year     qty1&lt;/P&gt;&lt;P&gt;1                   1           2006    70.00&lt;/P&gt;&lt;P&gt;1                   2           2006    10.00&lt;/P&gt;&lt;P&gt;and this addition should be done for last 12 months from the current date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;Nishu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2006 13:07:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756740#M327823</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-21T13:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching data for las 12 Months</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756741#M327824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT cust matno year month qty1&lt;/P&gt;&lt;P&gt;into table itab&lt;/P&gt;&lt;P&gt;from ztable&lt;/P&gt;&lt;P&gt;where year in r_year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ldt = sy-datum - 365.&lt;/P&gt;&lt;P&gt;concatenate ldt(6) '01' into ld2.&lt;/P&gt;&lt;P&gt;ld1 = sy-datum.&lt;/P&gt;&lt;P&gt;Loop at itab.&lt;/P&gt;&lt;P&gt;  concatenate itab-year itab-month '01' into ldate.&lt;/P&gt;&lt;P&gt;  check ldate &amp;lt;= ld1 and ldate &amp;gt;= ld2.&lt;/P&gt;&lt;P&gt;  move-corresponding itab to itot.&lt;/P&gt;&lt;P&gt;  collect itot.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2006 13:16:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756741#M327824</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-21T13:16:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching data for las 12 Months</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756742#M327825</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;PRE&gt;&lt;CODE&gt;DATA: PERIOD(6) TYPE N,
           PERIOD_FROM(6) TYPE N,
           PERIOD_TO(6)       TYPE N.

PERIOD_FROM(6) = SY-DATUM(4).
PERIOD_TO(4)       = SY-DATUM(4).
PERIOD_TO+4(2)   = '12'.

LOOP AT ITAB.
  PERIOD(4)     = ITAB-YEAR.
  PERIOD+4(2) = ITAB-MONTH. 
  IF PERIOD =&amp;gt; PERIOD_FROM AND PERIOD &amp;lt;= PERIOD_TO.
    COLLECT ITAB INTO ITAB2.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2006 13:23:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756742#M327825</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-21T13:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching data for las 12 Months</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756743#M327826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA: V1(4) TYPE N,&lt;/P&gt;&lt;P&gt;           V2(2) TYPE N,&lt;/P&gt;&lt;P&gt;           V3(2) TYPE N.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;V1 = SY-DATUM+0(4) - 1.&lt;/P&gt;&lt;P&gt;V2 = SY-DATUM+4(2).&lt;/P&gt;&lt;P&gt;V3 = SY-DATUM+6(2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;contatenate V1 V2 V3 into date1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from z-table into itab where date &amp;lt;= sy-datum&lt;/P&gt;&lt;P&gt;                                           and    date &amp;gt;= date1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2006 13:43:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756743#M327826</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-12-21T13:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching data for las 12 Months</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756744#M327827</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;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;) calculate previous_year = sy-datum(4) - 1.
2) calcualate period_from  = sy-datum+4(2) + 1.
   if period_from &amp;gt; 12.
      period_from = 1.
      prvious_year = sy-datum(4).
   endif.

3) select yout table with where clause:

where ( ( year = previous year 
   and month between previous_month and 12 )
     or year = sy-datum(4)  
   and month between 1 and sy-datum+4(2) ) )
...
  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Dec 2006 13:58:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/fetching-data-for-las-12-months/m-p/1756744#M327827</guid>
      <dc:creator>andreas_mann3</dc:creator>
      <dc:date>2006-12-21T13:58:50Z</dc:date>
    </item>
  </channel>
</rss>

