cancel
Showing results for 
Search instead for 
Did you mean: 

display last 12 months

Former Member
0 Kudos

HI,

I have a requirement of displaying the data of last 12 months, month wise. If i give an input as Dec 2009, it should diplay data from Jan 2009 to Dec 2009 separately as follows

Jan 2009

Feb 2009

March 2009

---

---

Dec 2009.

The above can be achieved by creating 12 selections and changing the offset. But i want to know is there any better way of doing?

Regards.

Prasad

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prasad,

You have to drag the characteristic Calendar Year/Month in the columns above the Keyfigure.

Create a User entry variable for getting the date ( You can use an SAP Exit variable if you want current date).

In the Query Designer, choose Restrict and from the Drop down box, select value Ranges -> Between.

Click on 'Select from List' and in the Dropdown box, Choose Variables.

Select the variable you have created in both the fields (Same variable can be used for both From value and To value). Transfer the selection to the right side and specify Variable offset. Enter -12 (Last 12 months from current date) and when it prompts for second time, Select 0 (Current month). Save and execute the query.

Hope this suits your requirement.

Regards,

Hari

Edited by: Hari Krishnan K on Jul 22, 2010 6:23 PM

Former Member
0 Kudos

HI,

Thanks for your reply.

I tried the procedure suggested by you. But by doing that i am getting the consolidated value of last 12 months in one column. May be I have to create customer exit.

Looking forward to ur suggestion on this.

Regards.

Prasad

Former Member
0 Kudos

Hi,

You need to have calyear/month (On w2hich you are outting the input variable )object in display then you will not get consolidated value. You will get monthly value just include cal year month in columns.

I hope it will help.

Thanks,

S

Former Member
0 Kudos

Hi Prasad, Did you include the infoobject CalYear/Month in the columns. (Please see my post above.) Then it will display last 12 months starting from user entered month. No need for Customer exit variable.

Regards,

Hari

Former Member
0 Kudos
DATA : V_SPMON(2),V_YEAR(4).
WHEN 'ZTESTVAR'.
IF I_STEP = '1'.
	LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'YOUR_VAR.........'. 
		V_SPMON = LOC_VAR_RANGE+4(2).
		V_YEAR = LOC_VAR_RANGE+0(4).
	IF V_SPMON=12.			
		V_SPMON = V_SPMON-12.			
		CONCATENATE V_YEAR V_SPMON INTO L_S_RANGE-LOW.			
	ELSE.			
		V_YEAR = V_YEAR-1.			
		CONCATENATE V_YEAR V_SPMON INTO L_S_RANGE-LOW.		
	ENDIF.	
	*       L_S_RANGE-HIGH = (user entry..............)
        	L_S_RANGE-SIGN = 'I'.
        	L_S_RANGE-OPT = 'EQ'.
        	APPEND L_S_RANGE TO E_T_RANGE.
      ENDLOOP.
ENDIF.
Former Member
0 Kudos

1st you would need to define the 0CALMONTH2 (say Period: 03.2009) variable in global: filter/char restriction level of query designer. SAP considers the same as 200903. So, this logic will help you determine the past 12 months as you enter in the user input.

+f M=12 then M=M-12
year = SOURCE_FIELDS-ZMON+4(2)
concatenate year MM
else
YYYY = YYYY - 1
month = 12-month
concatenate year month

Based on this, we can determine dynamically the range for the variable using I_STEP=1. Now, the question comes how to display the 12 months? Hmmm.. You may click drag the 0CALMONTH2 (Calendar Month-Year) onto the columns. Next create a structure for the same in the columns, where you add certain restrictions for your query. Pls. note the restrictions for the 0CALMONTH2 shall be done at global level, & care to be taken not to locally restrict within the structure. Use the customer exit variable in this restriction, followed by using your KPIs/Key figures on the rows. Guess that will suffice.

Edited by: Arun Bala G on Jul 24, 2010 6:41 AM

Former Member
0 Kudos

Follow the steps

1. Drag the Calendar Month over the Key Figure structure in Columns.

2. Go to Filter Tab and Drag the Calendar Month in Filter Section.

3. Right Click and Restrict

4. Select Range from the top drop down

5. Select Between on the next screen

6. Select one user input variable for Calendar month in both the variables

7. Pass them into the selection by pressing right arrow button

8. select the selection and right click and select "offset"

9. in the first screen instead of 0 make it -11 -> OK.

10. On the second screen for offset, let it be 0 only.

11. OK

Run the query and see the result.

- Danny

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Prasad,

Please close the thread if the issue is resolved sothat it will help others who is searching SDN forums for a similar requirement.

Thanks & Regards,

Hari Krishnan K.

Former Member
0 Kudos

Prasad,

The first reply to your post by HariKrishnan is the correct reply. thats all what you require. Try it and I am sure it would solve your problem.

rgds,

Sree

Former Member
0 Kudos

Hi,

You may try this.

Create one input variable for which you will get that required month.

Create one exit variable on this variable and assign value as "value got from inout variable - 12 months".

Now put global filter on calyear/month with those two variable. For input variable condition should be <= and for exit it should be >=.

Take Cal Year/Month in default display. It will display last 12 months automatically.

I hope it will help.

Thanks,

S