<?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: CHALLANGE : EXPLAIN THIS CODE!!! in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933014#M386191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi tejas,&lt;/P&gt;&lt;P&gt;  Looks like it is a function module which computes the number of years between two dates.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Feb 2007 13:46:13 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-12T13:46:13Z</dc:date>
    <item>
      <title>CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933012#M386189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HELLO TO ALL EXPERTS,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HERE IS A PIECE OF SIMPLE CODE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KINDLY EXPLAIN.&lt;/P&gt;&lt;P&gt;_____________________________________________________________________&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(DATE1) LIKE  PA0000-BEGDA
*"     VALUE(MODIFY_INTERVAL) DEFAULT ' '
*"     VALUE(DATE2) LIKE  PA0000-BEGDA
*"  EXPORTING
*"     VALUE(YEARS_BETWEEN_DATES)
*"  EXCEPTIONS
*"      SEQUENCE_OF_DATES_NOT_VALID
*"----------------------------------------------------------------------

CASE MODIFY_INTERVAL.
  WHEN '+'. DATE1 = DATE1 - 1.
  WHEN '-'. DATE1 = DATE1 + 1.
  WHEN OTHERS.
ENDCASE.

IF DATE1+4(4)  EQ '0229' AND
   DATE2+4(4) EQ '0228'.
   DATE2 = DATE2 + 1.
  IF DATE2+4(4) EQ '0229'.
   DATE2 = DATE2 - 1.
  ENDIF.
ENDIF.


IF DATE1 LE DATE2.
  IF DATE1+4(4) LE DATE2+4(4).
    YEARS_BETWEEN_DATES = DATE2(4) - DATE1(4).
  ELSE.
    YEARS_BETWEEN_DATES = DATE2(4) - DATE1(4) - 1.
  ENDIF.
ELSE.
  YEARS_BETWEEN_DATES = 0.
  RAISE SEQUENCE_OF_DATES_NOT_VALID.
ENDIF.&amp;lt;/b&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;_____________________________________________________________________&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THANKS!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 13:39:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933012#M386189</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T13:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933013#M386190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the problem?? It caculates the number of yearts between 2 dates...&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;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 13:43:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933013#M386190</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T13:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933014#M386191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi tejas,&lt;/P&gt;&lt;P&gt;  Looks like it is a function module which computes the number of years between two dates.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 13:46:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933014#M386191</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T13:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933015#M386192</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;This code is from the FM COMPUTE_YEARS_BETWEEN_DATES for calculating years between days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;U can see the same in debugging mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When Interval = + the starting date + 1.&lt;/P&gt;&lt;P&gt;If interval  = - then starting date -1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If teh date1 starting date is equal to 29th Feb and End date is 28th Feb add one to end date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If date2 i.e end date is equal to 29th Feb subtract one from that.&lt;/P&gt;&lt;P&gt;If date1 is less than date2 find teh difference between date1 and date2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If date2 is less tahn date1 find teh difference between date1 and date2 and subtract one from them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this is clear.&lt;/P&gt;&lt;P&gt;U can find this in debugging mode.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 14:05:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933015#M386192</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T14:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933016#M386193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To ALL,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your kind and appreciate efforts!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I'm still not clear with this code.&lt;/P&gt;&lt;P&gt;I want to know how each and every syntax works. what are the inputs and outputs of each syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly Help!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 07:50:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933016#M386193</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T07:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933017#M386194</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;This we cant expalin by typing, u have to debug the code by passing some values.&lt;/P&gt;&lt;P&gt;Put a breakpoint at the starting and see.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For single step execution press F5 and click on date1 and date2 to see how the values are in debugging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you see line by line in debuggin u can be more clear.&lt;/P&gt;&lt;P&gt;Pass Feb 29 and Feb 28 to understand more clearly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope u have the code which I gave in the last post.&lt;/P&gt;&lt;P&gt;So create a test program paste the code and try to debug.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 08:01:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933017#M386194</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T08:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933018#M386195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Query : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"DATE1+4(4)  EQ '0229'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What does this syntax mean??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 08:02:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933018#M386195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T08:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933019#M386196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Date is of type DATS 8.&lt;/P&gt;&lt;P&gt;So if FEB 29 2006 will be as 20060229 in debugging u can see this.&lt;/P&gt;&lt;P&gt;So +() means offset of.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If date = '20060229'.&lt;/P&gt;&lt;P&gt;For taking year u have to specify date+0(4) which is equal to 2006.&lt;/P&gt;&lt;P&gt;For month and year date+4(4) which will return '0229'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want month alone date+4(2).&lt;/P&gt;&lt;P&gt;If you want date alone  date+6(2).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It starts with 0, so 0 -7 count.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sy-datum format is YYYYMMDD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope u r clear now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Judith Jessie Selvi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 08:04:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933019#M386196</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T08:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933020#M386197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In general DATE1+a(b) means the part of DATE, from b number of characters starting from 'a'th position.&lt;/P&gt;&lt;P&gt;if date1 = 20070229, then date1+4(4) will be 0229.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 08:09:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933020#M386197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T08:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: CHALLANGE : EXPLAIN THIS CODE!!!</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933021#M386198</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 we know that date variable is of size 8 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SAP it is stored as YYYYMMDD. i.e. for example 2nd October, 2006 will be stored in SAP as 20061002.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date1+4(4) means MMDD of YYYYMMDD. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax is &lt;/P&gt;&lt;P&gt;Variable+offset(length).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case if you refer date1+0(4), you will get YYYY. i.e. starting from 0, next 4 digits in the variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this will solve your purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Navin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Feb 2007 08:42:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/challange-explain-this-code/m-p/1933021#M386198</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-13T08:42:20Z</dc:date>
    </item>
  </channel>
</rss>

