Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Subtraction 3 months from current month and store in a report output

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.

Tags:
replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question