cancel
Showing results for 
Search instead for 
Did you mean: 

Weekly Avarage Report.

praveen_kumar155
Explorer
0 Kudos

Hi Guru,

I have 5 Weekly moving Average report with 2013 ,2014 data.

user will enter the week based on that week we need -4-3-2-1 like 5 and also we are calculating average.

but only we are getting which ever the selection i used.

ex :  24.2013 if i select  then it display 24,23,22,21,20 of that 2013 year week only

but our requirement is to display both the year how it is achieve please help me out.

Regards

Praveen.

Accepted Solutions (0)

Answers (5)

Answers (5)

santosh_hiremath
Explorer
0 Kudos

Sorry Praveen,

I was on vocation so i could not get a time to login. Did you get the solution or u want me to send you the required abap code.

Regards,

Santu.

Former Member
0 Kudos

Hi,

Any solution? I got a similar requirement.

Thanks,

Karthik

santosh_hiremath
Explorer
0 Kudos

Hi Praveen,

Refer to my previous comment, it will work.

Regards,

Santu

praveen_kumar155
Explorer
0 Kudos

Hi Santosh,

Am not an ABAPER please provide the code to get the previous year weeks

former_member202718
Active Contributor
0 Kudos

Hi Praveen,

I assume tht you have the CALDAY in you Cube/MP/Query.

Create a Var on Calyday and u wll get 14.01.2015.

Make this Date as 14.01..2014

Pass this date to FM DATE_GET_WEEK and this will give you 201403 (Current Week).

Do Offset for 201403 with -5  with Range...

I hope this gives an idea.

rgds

SVU

praveen_kumar155
Explorer
0 Kudos

Hi Svu 123,

In My Cube i dont have 0calday we have week month year qtr.

Regards

Praveen.

former_member202718
Active Contributor
0 Kudos

Then Praveen you can use FM WEEK_GET_FIRST_DAY to get the First day of the Week.

Pass 201503 and you will get 13.01.2015 and from there make this as 13.01.2014 and get the Calweek.

rgds

SVU

santosh_hiremath
Explorer
0 Kudos

Hi Praveen,

I did not get your requirement Can you tell us brief with an example...

Regards,

Santu.

praveen_kumar155
Explorer
0 Kudos

Hi Santosh,

i have 2 year of data  2013, 2014.

i want to do a report 5 weeks moving avarage report..

So i took 0calweek as a user entry, Based on the user gives the values ex 30.2014.

it as to display 30.2014, 29.2014,28.2014.27.2014,26.2014 and also as the same way previous year 30.2013,29.2013,28.2013.27.2013,26.2013 it as to display.

for that i have used offset for current week-1 -2 -3 -4. current week.

regards

Praveen.

santosh_hiremath
Explorer
0 Kudos

Hi Praveen,

Use CMOD code.

If user enters 30.2014 then

lv_var1 = 0calweek+0(4)--will give you calyear(2013)

lv_var2 = 0calweek+4(2)--will give you entered week(30)

then concatinate lv_var1 and lv_var2 to one more variable(ex: cmod_var) value=30.2013

then use offset on this variable(cmod_var)

it will give you 30.2013,29.2013,28.2013.27.2013,26.2013 30.2013,

for 2014 directly apply offset on input varable.

Regards,

Santu

santosh_hiremath
Explorer
0 Kudos

Correction :

Lv_var1 = calweek+0(4) - 1.

praveen_kumar155
Explorer
0 Kudos

hi Santosh,

i think you talking about customer exit.

Regards

Praveen

praveen_kumar155
Explorer
0 Kudos

Hi Santosh,

Could you please give me the code so that it help full for me.

i am not a abaper.

regards

Praveen

praveen_kumar155
Explorer
0 Kudos

Hi Santosh,

Am not a abaper, could you please give me a code so that i can use that code to get previous year week.

Regards

Praveen

former_member186399
Active Contributor
0 Kudos

Dear Praveen,

I think the requirement is to get average for 5 weeks of both 2013 and 2014 combined.

Hope you have both Cal week and year in your data target. You can create two selection at the query one for 2013 and one for 2014. Add these to selection in a formula and divide them with 10.

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Could you please elaborate more.

Regards

Praveen

former_member186399
Active Contributor
0 Kudos

Dear Praveen,

Do you calweek and calendar year in your data target.

If yes,

you should have 2 input variables, one for week and one for year.

Now create 2 selection one for current year with week interval with offset to 5 weeks.

The next selection will be for previous year (current year -1)  with week interval with offset to 5 weeks.

The above will give you 5 week wise data for 2013 and 2014.

Have I understood you correctly?

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Thanks for Replay, I created a Query Above u said but only displaying current year but not previous year.

former_member186399
Active Contributor
0 Kudos

Hello,

Where have you maintained the year restriction. It should be in local selection and not in the global restriction. can you put the screen shot of both selection that you have created

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Please find the Screen short which shows clear picture .

Regards

Praveen

former_member186399
Active Contributor
0 Kudos

Hello Praveen

Got your issue.

In the previous year selection for the calendar week give an  offset of 12 weeks. ZWEEKS-12.

As you are choosing 201405 as week in the input for the previous year has to fetch from 201305 week

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

If user will Change the input then also it will display the values right..

Regards

Praveen.

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

i have give -12 weeks offset for previous week i got the out put. but user will change the requirement then . how its works..

if need i will provide the screen short of original query.

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Please find the original requirement which am doing.

am sending the screen shorts..

for week .

for current  week-1

for current week -2

for current week-3

for current week -4.

here am selecting 05 2014.

and the out put is..this.

here am not getting the values of 2013, because am used current one what about the previous year to get values . please help me out.

former_member186399
Active Contributor
0 Kudos

Hello Praveen

You need not do the individual week calculation like that.

1) For current year use value ranges between and input the ZWEEK variable ( in both from and to)  and offset it by -5.  It will look like this

ZWEEK-5 - ZWEEK

2) For the previous year , put the value ranges as shown below using offset

ZWEEK-17-ZWEEK-12

you will get both current year and previous year value

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Thanks for Replay, i have done according you said that is working fine, now Am getting values.

but my requirement is what ever user input value enter ex: 05.2014 if he enter this value

then i need to show 05.2014     05.2013  both the years.

                             04.2014     04.2013

                             03.2014     03.2013

                             02.2014     03.2013

                             02.2014     03.2013 

like this i need to display the out put and provide the average.

former_member186399
Active Contributor
0 Kudos

Hello Praveen,

Then you will have to create individual week split as you had done previously, only that the Zweek variable remains the same.only you need to provide is the offset fo getting the prev year data.

You may need to use the cells to show yearwise average.

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hi Nagesh,

Thanks for Response.

then i need to create 5 new selection amount/Restrict - calenderyear/ 2013 - calweek/ ?

offset value present year 2013.

please let me know am confusion state. to get the correct value 2013 and 2014.

Regards

Praveen.

former_member186399
Active Contributor
0 Kudos

Hello Praveen,

I tried the same settings, its not possible to bring in the same format which you mentioned above. As the calendar week has the year part with it, for the same week the data will repeat in 2 different lines if you Cal week in the rows.

Another approach is to make sure that you have a characteristic in your cube which stores only the week part( imean for 01.2014 it stores only 01). you can use this to plot this for your reporting

Regards

Gajesh

praveen_kumar155
Explorer
0 Kudos

Hello Nagesh,

Please help me out is there any customer exit variable  i need to write for bring the previous year same calweek..

Regards

Praveen.

former_member186399
Active Contributor
0 Kudos

DATA: LV_YEAR TYPE /BI0/OIFISCYEAR.

DATA: LV_WEEK TYPE /BI0/OICALWEEK.

DATA: LV_ZWEEK TYPE /BI0/OIFISCYEAR.

DATA: LV_YEAR TYPE /BI0/OIFISCYEAR.
DATA: LV_PYEAR TYPE /BI0/OIFISCYEAR.

DATA: LS_VAR_RANGE TYPE  RRRANGEEXIT.
DATA: LS_OUT_RANGE TYPE RRRANGESID.

DATA: LV_WEEK TYPE /BI0/OICALMONTH2.

WHEN 'variable name'. ( new variable )

IF I_Step = 2.

READ TABLE I_T_VAR_RANGE INTO LS_VAR_RANGE

    WITH KEY VNAM = 'ZWEEK'.


    IF SY-SUBRC = 0.

      LV_YEAR = LS_VAR_RANGE-LOW+0(4).

     LV_WEEK =  LS_VAR_RANGE-LOW+4(2).

     LV_PYEAR = LV_YEAR-1.

      CONCATENATE LV_PYEAR  LV_WEEK INTO LV_ZWEEK.

      LS_OUT_RANGE-LOW = LV_ZWEEK.

      LS_OUT_RANGE-SIGN = 'I'.

      LS_OUT_RANGE-OPT = 'EQ'.

      APPEND LS_OUT_RANGE TO LT_OUT_RANGE.

      E_T_RANGE = LT_OUT_RANGE.

    ENDIF.

Regards

Gajesh