cancel
Showing results for 
Search instead for 
Did you mean: 

How do I filter Calendar Date by Fiscal Period?

0 Kudos


I have a BEx query which I need to filter.  The query has a ready for input variable for Fiscal Period and contains records with a Calendar Date.  Our Fiscal Year variant is K0 and matches the calendar year.  The requirement is for the Calendar Date records to be filtered by the Fiscal Period variable.  For example, if the user selects Fiscal Period 009/2014, the query should return only records with a Calendar Date greater than 09/30/2014, which is the last day of the period.  I am familiar with the function module LAST_DAY_IN_PERIOD_GET but am not sure how I could leverage that in my case.

Accepted Solutions (1)

Accepted Solutions (1)

Loed
Active Contributor
0 Kudos

Hi Derrick,

Create a customer exit for the filter of your CALENDAR DATE..Let's say, the variable used were VAR_FP and VAR_CD for FISCAL PERIOD and CALENDAR DATE, respectively..This will be your user exit..

*there is a code here something like this.....WHERE VARIABLE = 'VAR_FP'

*sorry, i'm at home so I can't remember exactly the codes

*just check the user exit in your system to know what i'm talking

data: temp_date like sy-datum.

CONCATENATE your_variable_low(4) your_variable_low+5(2) '01' into temp_date.

CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'

  EXPORTING

  day_in = temp_date

  IMPORTING

  last_day_of_month = VAR_CD

  "EXCEPTIONS

  "DAY_IN_NOT_VALID = 1

Just post here if you have query regarding my post..

Regards,

Loed

Answers (2)

Answers (2)

RafkeMagic
Active Contributor
0 Kudos

as explained by Loed Despuig you'll need a customer exit variable on calendar date

the code for this variable can be put in exit: EXIT_SAPLRRS0_001

you'll need a check on "i_vnam = <your new variable on calendar date>." and one on "i_step = 2."

next you'll need to read table "i_t_var_range" and look for <your variable on fiscal period>

then simply call your function (LAST_DAY_IN_PERIOD_GET) with the following parameter values:

I_GJAHR = <your variable on fiscal period>(4)

I_MONMIT = <leave empty>

I_PERIV = "K0"

I_POPER = <your variable on fiscal period>+4(3)

E_DATE = <a local date variable defined like sy-datum>

the last day of your period will be in E_DATE

sander_vanwilligen
Active Contributor
0 Kudos

Hi Derrick,

If I understand your requirement correctly, you want to restrict the F4 value help of Calendar Day based on the input of Fiscal Period. You might want to consider implementing BAdI RSR_VARIABLE_F4_RESTRICT_BADI (Enhancement Spot RSR_VARIABLE_F4_RESTRICT).

Please refer to the document for an example with restricting the F4 value help for Fiscal Period based on the previous Fiscal Year. You can also refer to the example implementation CL_RSR_VAR_F4_RESTRICT_EXAMPLE.

Best regards,

Sander