07-20-2007 7:53 AM
hi experts,
suppose the date is '010406' what i want that is der any function module so that i can get the first date of the previous month i.e '010306' plz let me know......or sud i add logic for that if yes plz help me........
07-20-2007 8:00 AM
Hi You can use the code below.
DATA : V_DATE TYPE SY-DATUM value '20070720'.
V_DATE+6(2) = '01'. "First day of current month.
CALL FUNCTION 'SG_PS_ADD_MONTH_TO_DATE'
EXPORTING
months = '-1'
olddate = v_date
IMPORTING
NEWDATE = v_date
.
write:/ v_date.
<b>Reward if helpful</b>
07-20-2007 7:57 AM
use fm:
date_to_day...
data day type DTRESR-WEEKDAY.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
DATE = '01/03/07'
IMPORTING
WEEKDAY = day
.
write day.
Message was edited by:
abapuser
07-20-2007 8:00 AM
Hi You can use the code below.
DATA : V_DATE TYPE SY-DATUM value '20070720'.
V_DATE+6(2) = '01'. "First day of current month.
CALL FUNCTION 'SG_PS_ADD_MONTH_TO_DATE'
EXPORTING
months = '-1'
olddate = v_date
IMPORTING
NEWDATE = v_date
.
write:/ v_date.
<b>Reward if helpful</b>
07-20-2007 8:03 AM
better to use own logic for your requirement....
suppose you have date field
data : date1 like sy-datum,
mon(2) type n,
year(4),
prev like sy-datum.
date1 = '20070720'.
mon = date1+4(2).
year = date1+0(4).
if mon ne '01'.
mon = mon - 1.
concatenate year mon '01' into prev.
else.
mon = '12'.
year = year - 1.
concatenate year mon '01' into prev.
endif.
write : / prev.
if the date is like your format i.e. 010406 then
data : date1(6) value '010406',
mon(2) type n,
year(4),
prev like sy-datum.
date1 = '20070720'.
mon = date1+2(2).
year = date1+4(2).
if mon ne '01'.
mon = mon - 1.
concatenate year mon '01' into prev.
else.
mon = '12'.
year = year - 1.
concatenate year mon '01' into prev.
endif.
write : / prev.
regards
shiba dutta
07-20-2007 8:05 AM
first get the first day of the previous month of the date.
for example u want the first date of july.
pass 01.06.2007.
to Functional module
call function 'RP_LAST_DAY_OF_MONTHS'
exporting
day_in = 01.06.2007
importing
last_day_of_month = l_dat_mon
exceptions
day_in_no_date = 1
others = 2 .
l_dat_mon holds the last day of june.
then add l_dat_mon + 1 .
u will get the date..
reward if useful
07-20-2007 8:10 AM
try this FM,
/BEV4/PLPS__ADD_MONTH_TO_DATE.
for months give input as '-1' .
award points if it helps.
07-20-2007 8:46 AM
if u have the current month...
u can concatenate '01' currentmonth - 1 year.
if current month = 1.then take month as 12 and year = year-1 and concatenate