10-18-2008 1:26 PM
Hi Gurus,
Currently my requirement is my clinet is having 2 sales organization one in usa and one in china.
They are using one report for sales comparison. The issue is when client enter the sales organization number like 1002 for china the output should like
Period 06 => SEP (usa spetember amount should come in 1002 organization june filed in the report
Period 07 => OCT(like wise oct amount for in august. This process should continue for every month.
provide sample program or logic.
10-18-2008 3:59 PM
Subtracting days to determine month is not a good idea, as each month can have different number of days.
If you want to be precise act on month value in date like this:
data: period type i, "data for stroing period
c_period(2) type n. "period in format 01,02, 03
period = sy-datum+4(2) - 3. "take 3 months before actual date
"if the result is less or equal 0 (then we have to back to to previous year)
"it will be applicable only for JAN, FEB and MARCH months
if period le 0.
ADD 12 to period.
endif.
c_period = period. "now in c_period you have 3 months before today
10-18-2008 1:37 PM
Hi Venky,
Try this logic .. hold the current date sy-datum in a local variable and then substract the 2 months days (60 days).
DATA: DAT(10) TYPE C.
ZDATEHISTORY-DAT6 = ( ZORMA-DAT ) - 60.
Hope my answer helps you.
Cheers!!
Reddy
10-18-2008 3:52 PM
Try FM HR_HK_ADD_MONTH_TO_DATE.
Give Operation as '-' to subtract months.
Regards
Karthik D
10-18-2008 3:59 PM
Subtracting days to determine month is not a good idea, as each month can have different number of days.
If you want to be precise act on month value in date like this:
data: period type i, "data for stroing period
c_period(2) type n. "period in format 01,02, 03
period = sy-datum+4(2) - 3. "take 3 months before actual date
"if the result is less or equal 0 (then we have to back to to previous year)
"it will be applicable only for JAN, FEB and MARCH months
if period le 0.
ADD 12 to period.
endif.
c_period = period. "now in c_period you have 3 months before today
10-18-2008 4:19 PM
In my opinion i would not suggest to substract the days directly but would be better
to let the calculation handle by FM like RP_CALC_DATE_IN_INTERVAL.
Month can have 28 / 29 / 30 / 31 as end dates so substracting 60 everytime will not be a good task.
Ex:
28 + 31 = 59 which can fail in a non leap year ..
In the FM To the reference date pass + sign and months by 02/03 this will add and with - sign u can push the date back to +/- 2/3 months .
I think u can just mould the logic based on this .
br ,
vijay.