cancel
Showing results for 
Search instead for 
Did you mean: 

variable offset for date - a year ago

Former Member
0 Kudos

I have this sales report with the following columns:

1. Current Day Sales

2. Month to Date Sales (this Year)

3. Month to Date Sales (last Year)

I'm using a range variable for 0CALDAY for column 2 (Month to Date Sales this year). i'm having problem with column 3. how is it possible such that the date is automatically assigned to last year's values? using offset would mean -365, however, this may not work during leap years?

please help

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Refer the 'Examples for using Variables' in 'Bex Query designer' of sap help..

Examples for Offset Variables

You want to use a query to carry out a comparison of two years.

Year Comparison

You want to compare the costs of a year of your choice with the costs of the previous year.

1. In the Query Designer, create a new structure and add a new Selection for each year that you require.

2. Only use one key figure (for example revenue) in this example query. Add this key figure to the filter or add it to the selection.

3. Use a characteristic value variable for the characteristic Calendar Year (0CALYEAR):

Select the characteristic value variables for Calendar Year and, from the context menu (right mouse click), choose New Variables. The Variables Wizard appears.

If you always want to reference to the current year automatically, use the SAP Exit variable 0CALYEAR (or as appropriate for another time characteristic).

4. Move the defined characteristic value variable into the selection.

5. Select the characteristic value variable and from the context menu (right mouse click), choose Restrict.

a. Select the characteristic value variable and from the context menu, choose Enter Variable Offsets.

b. Enter –1 as the offset and choose OK.

6. Choose OK.

7. Enter a description.

Example: Use the name of the key figure, for example, revenue, for the name and use a text variable for the name of the calendar year. See Using Text Variables.

When creating a new text variable, enter Replacement Path as the processing type, and choose calendar year 0CALYEAR as the characteristic with display as key.

8. Create a second selection with the same characteristic value variable and do not set an offset here.

Also use a text variable in the description in this case.

9. Move the required characteristic into the rows.

10. Save the query.

After execution, the query should appear as follows:

Variable screen entry: 2002 (or no entry when using the SAP Exit Variable).

Year Comparison

A characteristic

Revenue 2001

Revenue 2002

Value 1

100.000

90.000

Value 2

200.000

180.000

Value 3

300.000

400.000

Comparison with Cumulative Previous Year Period

For example: You want to compare the periods 1-8 of a particular year with the same periods for the previous year.

...

1. Create a new structure in the Query Designer and add a new Selection.

2. Move a key figure, for example, Revenue, into the selection.

3. Use a characteristic value variable for the characteristic Fiscal Year/Period (0FISCPER):

Select the characteristic value variables for Fiscal Year/Period and from the context menu, choose New Variable. The Variables Wizard appears.

Use the SAP Exit variable Current Fiscal Year/Period (0FPER) if you always want to reference to the current year. If you set the variable as entry-ready in the Variable Editor, after executing the query, the variable screen then appears with which you can change the default values were necessary.

4. Move the characteristic value variable, such as OFPER, into the selection.

5. Select the characteristic value variable and from the context menu (right mouse click), choose Restrict.

6. Under Selection, choose Value Area and choose the tab page Variables.

7. Add the characteristic value variable, for example 0FPER, to the selection once again for the second value of the interval.

8. Select the characteristic value variable and from the context menu, choose Enter Variable Offsets.

a. As an offset, enter -3 as the from value and 0 as the to value. Choose OK.

b. Choose OK.

9. Enter a description, such as Revenue for current year.

10. Choose OK.

11. Select the selection and from the context menu, choose Copy and then Paste.

12. Now select the second selection and from the context menu, choose Edit.

13. Select the characteristic value variable and from the context menu (right mouse click), choose Restrict.

14. Select the characteristic value variable again and from the context menu (the right hand button), choose Enter Variable Offsets.

a. As an offset, enter -15 as the from value and -12 as the to value. Choose OK.

b. Choose OK.

15. Enter a description, for example Revenue for previous year.

Also use a text variable in the description in this case.

16. Choose OK.

17. Move the required characteristic into the rows.

18. Save the query.

After execution, the query should appear as follows:

Variable screen entry: 01. 2002 to 08. 2002

Comparison with Cumulative Previous Year Period

A characteristic

Revenue 01. – 08. 2001

Revenue 01. – 08. 2002

Value 1

100.000

90.000

Value 2

200.000

180.000

Value 3

300.000

400.000

...

...

...

Two text variables replaced with characteristic values were used for the descriptions here. One is filled with the from-value for the column with an offset of 0 and a length of 3, the other filled with the to-value with an offset of 0 and a length of 7. You can find additional information under Example for Variable Replacement.

Comparison of Cumulated Values for Two Years

You may want to compare the cumulated values up to the current period of the current year with those of the previous year.

For this example, use the variable 0FPER (current fiscal year period) and the variable 0P_FPER (your chosen fiscal year period). You use these two variables to set the interval limits.

...

1. In the Query Designer, create a structure with two selections:

¡ 1. selection: Cumulative Amount for current year

¡ 2. selection: Cumulative amount for previous year

2. With the first selection (cumulative amount for current year) , move the time characteristic 0FISCPER into the selection and select it.

3. Choose Restrict from the context menu (right mouse click).

4. Choose Value Area between as the selection and go to the tab page Variables.

5. Double click to choose the variable 0P_FPER as the from value and variable 0FPER as the to value. The result is an interval from the chosen period to the current period.

6. Define the second selection (cumulative amount for previous year) and proceed as for the first selection.

¡ Add the variable 0P_FPER as the from value and variable 0FPER as the to value here.

¡ Set an offset of –12 for both the from and the to values:

Select the interval and from the context menu (right click), choose Enter Variable Offsets. Enter –12 for each.

The result is an interval that has been moved 12 periods ahead.

7. Add the key figures and additional characteristics for the query.

After executing the query, you get a variable screen for the variable 0P_FPER. You need to enter the start period in the current fiscal year.

You can also suppress this entry by deactivating the indicator Entry-ready in the Variable Editor for the variable 0P_FPER and entering a default value (for example, 001.2001 for 2001). You only have to change this value once per year.

You have now defined a query that compares the cumulative values for two years.

The variables with SAP Exit delivered by SAP have the following behaviors:

Variable 0FPER (current fiscal year period): Displays the values of the current fiscal year period.

Variable 0P_FPER (any fiscal year period): Displays the values of any fiscal year period. You can set the fiscal year period in the variable screen when executing the query in any way you require.

Variable 0FYTCFP (fiscal year up to current fiscal year period): Displays the values of the first period up to the current period of the current fiscal year.

Variable 0FYTLFP (fiscal year up to previous fiscal year period): Displays the values of the first period up to the previous period (current period –1).

You need to use the variables 0FPER and 0P_FPER in the above example for the comparison of cumulative values for two years. When using the variables 0FYTCFP and 0FYTLFP, only values for one month are displayed for year transitions with an offset of –12.

Regards,

Prema

Former Member
0 Kudos

Hi Prema,

please note that the object i'm using is 0CALDAY. using -1 as offset would mean a day ago, not a year ago.

Former Member
0 Kudos

also, i cannot use 0YEAR here because the objective is to get month to date values, for example:

1. Current Date is 2006-05-13

2. Month to Date this year is from 2006-05-01 to 2006-05-13

3. Month to Date last year is from 2005-05-01 to 2005-05-13

the user only inputs values for item 2 above and everything else should be automatically filled.

Former Member
0 Kudos

Hi Prema,

yes, your above guide should work if i'm working on months and years only. my problem is that i'm working with DATES here. thanks much.

Former Member
0 Kudos

Hmm, Yeah. I got it now..

Hmm.. looks like offset won't help much here.. not sure it can be handles in customer exit also?

I think there was some post of Filling 2 variables from one user entry date.. Not able to find using search now.. if I got it will post back here..

No other thoughts at the moment..

~ Hari

Former Member
0 Kudos

Dear Edwin,

You might have acived column 2 by restricting it to current year on 0YEAR variable.

So simialrly you can also find, previous year variable on that.. if not, try the offset as -1 on the current year variable..

I think that should work fine..

regards,

Hari

Message was edited by: Hari Kiran Y

Former Member
0 Kudos

Hi,

In the offset you specify only -1. not -365.

refer this link to solve your problem..

http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm

Regards,

Prema