<?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: Date Validation and Printing in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226201#M1984040</link>
    <description>&lt;P&gt;I think that these function modules are not released. Anyway, no need of any function module, it's very easy to use classic ABAP statements for each of the questions.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jul 2020 12:40:31 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-07-14T12:40:31Z</dc:date>
    <item>
      <title>Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226198#M1984037</link>
      <description>&lt;P&gt;When I enter a date, it has to be validated and the following should be printed. &lt;/P&gt;
  &lt;P&gt;1. First and the last date of the current month of the entered date. &lt;/P&gt;
  &lt;P&gt;2. First and the last date of the previous month of the entered date. &lt;/P&gt;
  &lt;P&gt;3. First and the last date of the next month of the entered date. &lt;/P&gt;
  &lt;P&gt;I am not asking for the entire program but just a clue as to how to proceed. I am a beginner and yet to learn a lot. Any help would be appreciated. &lt;/P&gt;
  &lt;P&gt;Regards, &lt;/P&gt;
  &lt;P&gt;Srinath. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 09:08:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226198#M1984037</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-14T09:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226199#M1984038</link>
      <description>&lt;P&gt;Hi  &lt;SPAN class="mention-scrubbed"&gt;smummaka&lt;/SPAN&gt;,&lt;BR /&gt;That question was asked and answered so many times thus I would suggest using Google before posting question.  &lt;BR /&gt;&lt;A href="https://answers.sap.com/questions/4117371/how-can-i-get-statrt-date-of-month-to-end-date-of-.html" target="_blank"&gt;How can i get statrt date of month to end date of month.&lt;BR /&gt;&lt;/A&gt;Regards,&lt;BR /&gt;Bartosz&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 10:16:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226199#M1984038</guid>
      <dc:creator>ziolkowskib</dc:creator>
      <dc:date>2020-07-14T10:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226200#M1984039</link>
      <description>&lt;P&gt;No FMs necessary, just simple ABAP based on TYPE d or datum (abap type date) using character replacement as well as addition/subtraction:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report ZDEMO_DATE_FIRST_LAST_MONTH
*&amp;amp;---------------------------------------------------------------------*
REPORT zdemo_date_first_last_month.

PARAMETERS p_date TYPE d DEFAULT sy-datum.  " the entered date
DATA tempdate     TYPE d.                   " for calculation purposes

**********************************************************************
* 1) First and last of current month based on selected date
**********************************************************************
DATA firstofcurrmonth TYPE d.  " the first of current month based on selected date
DATA lastofcurrmonth  TYPE d.  " the last  of current month based on selected date

" 1.a) First of current month based on selected date
firstofcurrmonth = p_date(6) &amp;amp;&amp;amp; '01'. " We know each month starts on the 1st, this one is easy

" 1.b) Last of current month based on selected date
tempdate  = p_date(6) &amp;amp;&amp;amp; '28'.   " we know each month has at least 28 days
tempdate  = tempdate + 4.        " adding 4 days will bring us always into the next month
tempdate  = tempdate(6) &amp;amp;&amp;amp; '01'. " this will give us the first of the next month
lastofcurrmonth  = tempdate - 1. " subtracting one, will give us the last of current month

**********************************************************************
* 2) First and last of previous month based on selected date
**********************************************************************
DATA firstofprevmonth TYPE d.  " the first of previous month based on selected date
DATA lastofprevmonth  TYPE d.  " the last  of previous month based on selected date

" 2.a) Last of previous month based on selected date
" We already know the first of the current month, so simply subtract one
lastofprevmonth = firstofcurrmonth - 1.

" 2.b) First of previous month based on selected date
firstofprevmonth = lastofprevmonth(6) &amp;amp;&amp;amp; '01'.

**********************************************************************
* 3) First and last of next month based on selected date
**********************************************************************
DATA firstofnextmonth TYPE d.  " the first of next month based on selected date
DATA lastofnextmonth  TYPE d.  " the last  of next month based on selected date

" 3.a) First of next month based on selected date
" We could have grabbed this date already from step 1.b)
firstofnextmonth = lastofcurrmonth + 1. " But we can also simply add 1 to the last of the current month

" 3.b) Last of next month based on selected date
tempdate  = firstofnextmonth(6) &amp;amp;&amp;amp; '28'. " same logic as in step 1.b)
tempdate  = tempdate + 4.                " adding 4 days will bring us always into the next month
tempdate  = tempdate(6) &amp;amp;&amp;amp; '01'.         " this will give us the first of the next, next month
lastofnextmonth  = tempdate - 1.         " subtracting one, will give us the last of next month

**********************************************************************
* Display dates
**********************************************************************
cl_demo_output=&amp;gt;write( p_date ).

cl_demo_output=&amp;gt;write( firstofcurrmonth ).
cl_demo_output=&amp;gt;write( lastofcurrmonth ).

cl_demo_output=&amp;gt;write( firstofprevmonth ).
cl_demo_output=&amp;gt;write( lastofprevmonth ).

cl_demo_output=&amp;gt;write( firstofnextmonth ).
cl_demo_output=&amp;gt;write( lastofnextmonth ).

cl_demo_output=&amp;gt;display( ).
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1824000-abap-date-last-first-of-month.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 11:04:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226200#M1984039</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-07-14T11:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226201#M1984040</link>
      <description>&lt;P&gt;I think that these function modules are not released. Anyway, no need of any function module, it's very easy to use classic ABAP statements for each of the questions.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 12:40:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226201#M1984040</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-07-14T12:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226202#M1984041</link>
      <description>&lt;P&gt;Thanks for the code. But, I am trying to call the method using the class to display the output but it is saying "cl_demo_output" does not exist. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2020 19:05:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226202#M1984041</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-07-14T19:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date Validation and Printing</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226203#M1984042</link>
      <description>&lt;SPAN class="mention-scrubbed"&gt;smummaka&lt;/SPAN&gt;, dont worry too much about this SAP standard class not being existing in your system. I just added that to help visualize the output.The class CL_DEMO_OUTPUT is part of the SAP package SABAP_DEMOS_OUTPUT_STREAM, and I have it present in a SAP CRM 731 application, a SAP ERP 6.0 740,  as well as in a S/4 HANA 754. Just wondering, what is your SAP application and what is the SAP_BASIS or the SAP Netweaver release?</description>
      <pubDate>Tue, 14 Jul 2020 20:32:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/date-validation-and-printing/m-p/12226203#M1984042</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-07-14T20:32:50Z</dc:date>
    </item>
  </channel>
</rss>

