‎2007 Feb 07 2:44 PM
hi guys,
i need to create a Date format in this format MM.YYYY ex: 02.2007 but in the data base it shoud store in this format 01.02.2007 ( first day of every month ) and i need to check validation for month MM ( should be 1 to 12 ).
i used it with handling it with sy-datum but i dunt want system or application date, i want user to enter date and when we use sy-datum it default take system date.
i want to even calculate end date of every month i.e for feb 29.02.2007, for march 31.03.2007 and store it in variable.
please can any one give me a piece of code for this because requirement is urgent.
Thanks
pavan kumar
‎2007 Feb 07 2:48 PM
use FM
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = sy-datum
IMPORTING
LAST_DAY_OF_MONTH = v_lastdate.or
call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = g_t_date-begin
IMPORTING
last_day_of_month = g_t_date-end.to get the last date of a month
‎2007 Feb 07 2:48 PM
use FM
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = sy-datum
IMPORTING
LAST_DAY_OF_MONTH = v_lastdate.or
call function 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = g_t_date-begin
IMPORTING
last_day_of_month = g_t_date-end.to get the last date of a month
‎2007 Feb 07 2:55 PM
well those FM are kewl, BUT they are not working correctly.
e.G. the last day of February 2007 is the 29th.
both FM´s calculate the 28th.
‎2007 Feb 07 2:57 PM
hi Florian,
last day of February 2007 is 28 only ... it is 29 for 2008 ..
regards,
Santosh
‎2007 Feb 07 3:01 PM
‎2007 Feb 07 2:51 PM
i´d advice you to use a real date since it would be a hard way to store half a date.
Anyway make yourself a date variable:
DATA lv_date type sy-datum.
write lv_date(2), lv_date(5)+5.
should give you "MM.DDDD".
‎2007 Feb 07 2:53 PM
say user entered 102007 on selection screen...
then, V1 = date+0(2).
check whether V1 lies between 01 & 12.
then V2 = date+2(4).
concatenate V1 '01' V2 into final date.
for getting last date use the below....
CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
DAY_IN = sy-datum
IMPORTING
LAST_DAY_OF_MONTH = v_lastdate.