<?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: factory date calculations in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904236#M55788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have used the function module DATE_CONVERT_TO_FACTORYDATE to do this on several occasions.  The only stipulation is that the Factory calendar must be maintained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module has a parameter CORRECT_OPTION that you can set to + or -.  If this parameter is set to + you input a date and a factory calendar and if the date is not a working day it will return the next working day.  If this parameter is set to -  and the input date is not a working day then it will return the previous working day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, in your example you can add the 4 days to the date call the function module and get back the same day if it is a work day or (depending on how you set the parameter) get back either the next work day or the most recent work day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could even increment the days in a loop calling the function module for each and advance the days by work days only skipping over holidays and weekends.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Apr 2005 22:22:39 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-04-27T22:22:39Z</dc:date>
    <item>
      <title>factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904234#M55786</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;I want to do some caculations based on the factory calander. Its like :&lt;/P&gt;&lt;P&gt;date = 04/27/2005. &lt;/P&gt;&lt;P&gt;I want to substract 4 days from this. But in case the new date is a leave day (Saturday/ sunday) then it should return the last working day along with the weekday like monday. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So here its saurday, so it should return 04/22/2005 friday, instead of 04/23/2005 saturday. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this calculation. Please advise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 20:54:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904234#M55786</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-27T20:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904235#M55787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Simi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use Function Module END_TIME_DETERMINE. You can supply a negative number for duration. The default unit is DAY. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Ramki.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 21:10:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904235#M55787</guid>
      <dc:creator>ramki_maley</dc:creator>
      <dc:date>2005-04-27T21:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904236#M55788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have used the function module DATE_CONVERT_TO_FACTORYDATE to do this on several occasions.  The only stipulation is that the Factory calendar must be maintained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function module has a parameter CORRECT_OPTION that you can set to + or -.  If this parameter is set to + you input a date and a factory calendar and if the date is not a working day it will return the next working day.  If this parameter is set to -  and the input date is not a working day then it will return the previous working day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thus, in your example you can add the 4 days to the date call the function module and get back the same day if it is a work day or (depending on how you set the parameter) get back either the next work day or the most recent work day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could even increment the days in a loop calling the function module for each and advance the days by work days only skipping over holidays and weekends.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2005 22:22:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904236#M55788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-27T22:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904237#M55789</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;Use these function modules&lt;/P&gt;&lt;P&gt;FACTORYDATE_CONVERT_TO_DATE    Calendar function: Returns date for a factory calendar date         &lt;/P&gt;&lt;P&gt;LAST_FACTORYDATE_GET           Calendar function: Return last factory date for a factory calendar  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Judith&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 06:18:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904237#M55789</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T06:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904238#M55790</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;You can try this : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="---------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  CHECK_FOR_HOLIDAYS&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="---------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;form check_for_holidays_plus using p_cal like scal-fcalid&lt;/P&gt;&lt;P&gt;                                   p_xdate type i&lt;/P&gt;&lt;P&gt;                          changing p_date like sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;p_cal is you calendar ID, you have to check in table &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;SCAL&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;p_xdate the nb of day you want to add&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;p_date the result date ( like sy-datum)&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  data: l_days type i value 1,&lt;/P&gt;&lt;P&gt;        l_found.&lt;/P&gt;&lt;P&gt;  data: l_attributes like thol occurs 0 with header line.&lt;/P&gt;&lt;P&gt;  p_date = sy-datlo.&lt;/P&gt;&lt;P&gt;  if p_xdate &amp;lt; 0.&lt;/P&gt;&lt;P&gt;    l_days = -1.&lt;/P&gt;&lt;P&gt;  endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  do.&lt;/P&gt;&lt;P&gt;    if ( l_days gt p_xdate and p_xdate &amp;gt; 0 ) or&lt;/P&gt;&lt;P&gt;       ( l_days lt p_xdate and p_xdate &amp;lt; 0  ).&lt;/P&gt;&lt;P&gt;      exit.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    if p_xdate &amp;gt; 0.&lt;/P&gt;&lt;P&gt;      p_date = p_date + 1.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      p_date = p_date - 1.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;    call function 'DATE_CONVERT_TO_FACTORYDATE'&lt;/P&gt;&lt;P&gt;      exporting&lt;/P&gt;&lt;P&gt;        date                         = p_date&lt;/P&gt;&lt;P&gt;        factory_calendar_id          = p_cal&lt;/P&gt;&lt;P&gt;      importing&lt;/P&gt;&lt;P&gt;        workingday_indicator         = l_found&lt;/P&gt;&lt;P&gt;      exceptions&lt;/P&gt;&lt;P&gt;        calendar_buffer_not_loadable = 1&lt;/P&gt;&lt;P&gt;        correct_option_invalid       = 2&lt;/P&gt;&lt;P&gt;        date_after_range             = 3&lt;/P&gt;&lt;P&gt;        date_before_range            = 4&lt;/P&gt;&lt;P&gt;        date_invalid                 = 5&lt;/P&gt;&lt;P&gt;        factory_calendar_not_found   = 6&lt;/P&gt;&lt;P&gt;        others                       = 7.&lt;/P&gt;&lt;P&gt;    if sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    if l_found eq space and p_xdate &amp;gt; 0.&lt;/P&gt;&lt;P&gt;      l_days = l_days + 1.&lt;/P&gt;&lt;P&gt;    elseif l_found eq space and p_xdate &amp;lt; 0.&lt;/P&gt;&lt;P&gt;      l_days = l_days - 1.&lt;/P&gt;&lt;P&gt;    else.&lt;/P&gt;&lt;P&gt;      clear l_found.&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;  enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endform.                    " CHECK_FOR_HOLIDAYS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&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;Erwan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2005 06:49:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904238#M55790</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-04-28T06:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: factory date calculations</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904239#M55791</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;Try this out&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  ADD_WORKING_DAYS&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Add n number of factory days(working days) to date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     &amp;lt;-- P_DAYS     Number of days to add&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     &amp;lt;-- P_PAYDATE  Starting date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM add_working_days USING p_days&lt;/P&gt;&lt;P&gt;                      CHANGING p_paydate TYPE sy-datum.&lt;/P&gt;&lt;P&gt;  DATA: gd_factorydat LIKE scal-facdate,&lt;/P&gt;&lt;P&gt;        gd_resdate    LIKE sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Convert date to factory date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            date                = p_paydate  "Starting date&lt;/P&gt;&lt;P&gt;            factory_calendar_id = 'GB'&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            factorydate         = gd_factorydat. "Factory calender date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Add n number of days to factory date, ignors non working days&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  gd_factorydat =  gd_factorydat + p_days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Convert factory date back to actual date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;  CALL FUNCTION 'FACTORYDATE_CONVERT_TO_DATE'&lt;/P&gt;&lt;P&gt;       EXPORTING&lt;/P&gt;&lt;P&gt;            factorydate         = gd_factorydat&lt;/P&gt;&lt;P&gt;            factory_calendar_id = 'GB'&lt;/P&gt;&lt;P&gt;       IMPORTING&lt;/P&gt;&lt;P&gt;            date                = gd_resdate. "Actual date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  p_paydate = gd_resdate.&lt;/P&gt;&lt;P&gt;ENDFORM.                    " ADD_WORKING_DAYS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;OR&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*&amp;amp;      Form  ADD_WORKING_DAYS_RESNONWORK&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;amp;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      Add n number of factory days(working days) to date, but allow &lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      resultant date to be a non working day&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     &amp;lt;-- P_DAYS     Number of days to add&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     &amp;lt;-- P_PAYDATE  Starting date&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="-----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM add_working_days_resnonwork USING p_days&lt;/P&gt;&lt;P&gt;                       CHANGING p_paydate TYPE sy-datum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA: ld_count  TYPE i.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ld_count = p_days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  WHILE ld_count GT 0.&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'DATE_CHECK_WORKINGDAY'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        date                       = p_paydate&lt;/P&gt;&lt;P&gt;        factory_calendar_id        = 'GB'&lt;/P&gt;&lt;P&gt;        message_type               = 'I'&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        date_after_range           = 1&lt;/P&gt;&lt;P&gt;        date_before_range          = 2&lt;/P&gt;&lt;P&gt;        date_invalid               = 3&lt;/P&gt;&lt;P&gt;        date_no_workingday         = 4&lt;/P&gt;&lt;P&gt;        factory_calendar_not_found = 5&lt;/P&gt;&lt;P&gt;        message_type_invalid       = 6&lt;/P&gt;&lt;P&gt;        OTHERS                     = 7.&lt;/P&gt;&lt;P&gt;    IF sy-subrc NE  4.&lt;/P&gt;&lt;P&gt;      p_paydate = p_paydate + 1.&lt;/P&gt;&lt;P&gt;      ld_count = ld_count - 1.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      p_paydate = p_paydate + 1.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;  ENDWHILE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDFORM.                    " ADD_WORKING_DAYS_RESNONWORK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Judith.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2005 06:32:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/factory-date-calculations/m-p/904239#M55791</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-05-04T06:32:57Z</dc:date>
    </item>
  </channel>
</rss>

