cancel
Showing results for 
Search instead for 
Did you mean: 

Month to date Variable

Former Member
0 Kudos

I have a requirement like to take month to date data for the past 13 month, like if today is 25th I have to take 1-25 of this month and 1-25 of past 12 months, the problem is if it 30 th or 31st , what about Feb month. Any one have experienced with this problem? Any abap codes?

Thanks for the help

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Roberto Negro

Thanks for the reply I have to take as per sys datum,no popups

Thanks!

Santhosh

Former Member
0 Kudos

You don't need lots of ABAP to do this. Make sure you store 0CALMONTH in the cube and create an InfoObject DAYOM (Day of Month) NUMC length 2. Fill it with 0CALDAY+6(2) (the last two digits of 0CALDAY) and you can the restrict 0CALMONTH with the last thirteen months and DAYOM with 1-x. The system doesn't check if every month has 31 days this way.

Best regards

Dirk

Former Member
0 Kudos

Hi Santhosh,

I think it's easy to code what do you want in the exit for the BEx variable. Just a question: do you need to calculate this range after a user entry in a pop-up or on the basis of SY-DATUM ??

Bye,

Roberto

Former Member
0 Kudos

Hi Roberto Negro

Thanks for the reply, by using variable(user-exit) I have to take as per sys datum,no popups

Thanks!

Santhosh

Message was edited by: santhosh sk

Former Member
0 Kudos

Hi Santhosh,

I can give you the solution if you want to use the BEx variable user-exit, but now I'll go to consider that you have into your infoprovider two time chars as 0CALMONTH and 0CALDAY.

If you have something different, let me know as soon as possible !

If you give me the ok, I'll post a code sample...

Bye,

Roberto

(and then, please don't forget to assign some points by clickin'on the star to the contributors that will help you !!!)

Former Member
0 Kudos

Hi Santhosh,

here is the solution !

As Dirk said, you have to create and insert into your provider a custom char called ZDAYOM (Day of Month) NUMC length 2 and fill it with 0CALDAY+6(2) (the last two digits of 0CALDAY).

On your query, create (if you want) a column for every month by restricting your KF with 0CALMONTH's 0CMONTH (this is the std variable for the actual month) and then use the offsets (right-click on the variable->specify variable offsets->-1, -2 and so on..)

In the BEx create also a variable (ZDAYNOW) with a customer exit as a processing type.

The variable is based on the InfoObject ZDAYOM.

Set the following attributes: Interval and Mandatory variable entry.

Call Transaction CMOD for the definition of the customer exit. Create a new project, maintain the short text and assign a development class.

Goto Enhancements Assignments and assign RSR00001.

Press the button components to continue.

EXIT_SAPLRRS0_001->Then double-click on ZXRSRU01.

If the include doesn’t exist you have to create it; assign a development class and a transport request.

Enter this coding:

[code ]

DATA: L_S_RANGE TYPE RSR_S_RANGESID.

DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.

CASE I_VNAM.

WHEN 'ZDAYNOW'.

CLEAR L_S_RANGE.

L_S_RANGE-LOW = '01'.

L_S_RANGE-HIGH = SY-DATUM+6(2).

L_S_RANGE-SIGN = 'I'.

L_S_RANGE-OPT = 'BT'.

APPEND L_S_RANGE TO E_T_RANGE.

ENDCASE.

[/code]

Save and activate the coding and activate the project.

Then you have to use this variable to restrict the KF already restricted before by the month (and related offsets).

Note that for the months that have got less days than the actual day, there is no problem, nothing will be selected for these 'missing' days !

Hope it helps.

Bye,

Roberto

Former Member
0 Kudos

Thanks Roberto

Thank you very much.

Santhosh

Former Member
0 Kudos

Santhosh,

please don't forget to assign some points by clickin'on the star to the contributors that will help you !!!

It's the way to thank someone in this forum !

Bye,

Roberto