‎2007 Jun 05 5:08 AM
hi friends,
given a period how to find previos month.
ie.
datum format is yyyymm.
datum = 200401
i should get previous month 200312
how do i do this.
‎2007 Jun 05 5:11 AM
Hi,
Try this..
DATA: V_INPUT(6) TYPE N VALUE '200401'.
DATA: V_OUTPUT(6) TYPE N.
DATA: V_DATE TYPE D.
CONCATENATE V_INPUT '01' TO V_DATE.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = '-1'
olddate = v_date
importing
newdate = v_date.
V_OUTPUT = V_DATE(6).
WRITE: / V_OUTPUT.
Thanks,
Naren
‎2007 Jun 05 5:11 AM
‎2007 Jun 05 5:11 AM
Hi,
Try this..
DATA: V_INPUT(6) TYPE N VALUE '200401'.
DATA: V_OUTPUT(6) TYPE N.
DATA: V_DATE TYPE D.
CONCATENATE V_INPUT '01' TO V_DATE.
call function 'RE_ADD_MONTH_TO_DATE'
exporting
months = '-1'
olddate = v_date
importing
newdate = v_date.
V_OUTPUT = V_DATE(6).
WRITE: / V_OUTPUT.
Thanks,
Naren
‎2007 Jun 05 5:12 AM
‎2007 Jun 05 5:14 AM
data :v_date(6) type c.
data v_dat(2) type c.
data :v_mon(2) type c
start-of-selection.
v_dat = v_date+4(2).
case v_dat.
when '01'.
v_mon = '12'
when '02'
v_mon = '01'
when '03'
v_mon = '02'
when '04'
v_mon = '03'
when '05'
v_mon = '04'
when '06'
when '07'
when '08'
when '09'
when '10'
when '11'
when '12'
endcase.
use case statement and concatenate to one more varaible
‎2007 Jun 05 5:16 AM
if you are talking about periods maintained in table t009 you can use this fm:
ISB_PREVIOUS_PERIOD_GET
‎2007 Jun 05 5:16 AM
Hi,
There are a lot of function module for Date caculations, so U can go to SM37 to find out the appropriate function for your use.
Hope this helps
Bob
‎2007 Jun 05 5:19 AM
Hi Saritha,
Try this simple coding.
DATA datum(6).
DATA last_month(6).
datum = '200501'.
If datum+4(2) = '01'.
last_month0(4) = datum0(4) - 1.
last_month+4(2) = '12'.
else.
last_month = datum - 1.
endif.
WRITE / last_month.
Regards,
Atish
‎2007 Jun 05 5:24 AM
Hi Saritha,
I'm not sure if there is a function module for this..
you can actually write the logic for this as follows:
data : date(6) value '200401'.
data : month(2), year(4).
data : final(6).
month = date+4(2).
year = date+0(4).
month = month - 1.
if month = 0.
year = year - 1.
month = 12.
endif.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = month
IMPORTING
OUTPUT = month
.
concatenate year month into final.
write : final.Hope this helps
Regards
Anil Madhavan
‎2007 Jun 05 5:33 AM
‎2007 Jun 05 5:35 AM
Hi,
Please make sure to reward points for helpful answers..and close the thread if the problem is solved..
Thanks,
Naren