cancel
Showing results for 
Search instead for 
Did you mean: 

Re: Fiscal year variant

sri_harsha2
Participant
0 Kudos

Hello Gurus,

I have an issue with the report the message displays when I try to run the report is " Fiscal year variant V0 is not maintained for Calendar year.

A selection is created in the structure whew 

0FISCPER =  Previous period Current Fiscal Year ( SAP Exit)

Version =   o1

Fiscal year variant =  April - March, 0 special periods [v0]

and in the description of the selection I am using a text variable " Previous year text" When I change the Text variable to "current fiscal year"

text this issue while up while running the report. I have tried out different ways listed in the other threads

Global settings looks fine , even the tables T009, T009 C have the V0 .. I tried even the below document,

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0a5a670-13f6-2c10-179d-a35e50a20...

I could not find the solution. Please give your valuable suggestions. Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

sri_harsha2
Participant
0 Kudos

Thank you Anshu, Loed. Below code worked out to some extent. But it was not displaying the months name instead it was displaying the number.

WHEN 'ZCALMOFY'.

       READ TABLE i_t_var_range INTO loc_var_range WITH

       KEY vnam = '0P_PRFP1'.

       ld_fiscyear = loc_var_range-low(4).

       ld_poper1   = loc_var_range-low+4(3).

       IF ld_fiscyear IS NOT INITIAL AND

          ld_poper1 IS NOT INITIAL.


       CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

         EXPORTING

           i_gjahr              = ld_fiscyear

*         I_MONMIT             = 00

           i_periv              = 'V0'

           i_poper              = ld_poper1

         IMPORTING

           e_date               = ld_fypdate

                 .

       lv_calmon = ld_fypdate(6).

       l_s_range-low = lv_calmon.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.

       ENDIF.



     This is displaying as 201502, this would need to be displayed as Feb 2015. I request you to

     advise on this if there is any way to change this.


     (The SPRO settings looks fine no issue with that)

Loed
Active Contributor
0 Kudos

Hi Sri,

Just hard code it..

WHEN 'ZCALMOFY'.

       READ TABLE i_t_var_range INTO loc_var_range WITH

       KEY vnam = '0P_PRFP1'.

       ld_fiscyear = loc_var_range-low(4).

       ld_poper1   = loc_var_range-low+4(3).

       IF ld_fiscyear IS NOT INITIAL AND

          ld_poper1 IS NOT INITIAL.


       CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

         EXPORTING

           i_gjahr              = ld_fiscyear

*         I_MONMIT             = 00

           i_periv              = 'V0'

           i_poper              = ld_poper1

         IMPORTING

           e_date               = ld_fypdate

                 .

       lv_calmon = ld_fypdate(6).

      if lv_calmon+4(2) = '01'.

            concatenate 'Jan' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '02'.

            concatenate 'Feb' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '03'.

            concatenate 'Mar' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '04'.

            concatenate 'Apr' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '05'.

            concatenate 'May' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '06'.

            concatenate 'Jun' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '07'.

            concatenate 'Jul' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '08'.

            concatenate 'Aug' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '09'.

            concatenate 'Sep' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '10'.

            concatenate 'Oct' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '11'.

            concatenate 'Nov' lv_calmon(4) into l_s_range-low.

      elseif lv_calmon+4(2) = '12'.

            concatenate 'Dec' lv_calmon(4) into l_s_range-low.

      endif.


       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.

       ENDIF.




Regards,

Loed

sri_harsha2
Participant
0 Kudos

Thank you all the Help Anshu, Loed, Sander

Answers (5)

Answers (5)

sri_harsha2
Participant
0 Kudos

Loed,

the report is broad casted, user would not get a chance to give any input variables.

But the report is generated from Fiscal period/ year. But user does not see the iputs, they

would be present only when report is run in analyzer. The report input variables would

be like below.


The input would be for the previous Fiscal period/year ( Feb 2014 : 10/2014). We get the results as per that, but the user

does not want the text varibale to be terms of fiscal period/year ( 10/2014 (Feb 2014).

Loed
Active Contributor
0 Kudos

Hi Sri,

If report is broadcasted, what is the purpose of ZPFYPER? Is it a variable with customer exit also?

What is the variable for the CALENDAR MONTH? What is the variable used by the report when it is being broadcasted? Or do you have two (2) queries? One for analyzer and one for broadcasting?


Regards,

Loed

sri_harsha2
Participant
0 Kudos

Hi Loed,

ZPFYPER is a variable with customer exit. The variable for Calendar month / year is ZTCALMOF.

The variable used by the report when it is being broadcasted is 0P_PRFP1. This displays the data for the previous fiscal period. There is only one query used for broadcasting. I tried using the above

code as well as hard code but it did not work. Please advise if I need to make changes to the code.

Loed
Active Contributor
0 Kudos

Hi Sri,

What's the code of ZPFYPER? OR what does it do?

Where do you use ZTCALMOF? I mean, if 0P_PRFP1 is used for broadcasting, what will be the function of ZTCALMOF? Where is it located in your query?

Regards,

Loed

sri_harsha2
Participant
0 Kudos

Loed,

ZTCALMOF is the text variable existing in the our system. 0P_PRFP1 is used for broadcasting and

ZTCALMOF is not used in this query. I have created the text variable ZCALMOFY that

would get the Calendar month/year from Fiscal period.

The code for ZPFYPER is

WHEN 'ZPFYPER'.

       cur_date = sy-datum - 1.

       CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

         EXPORTING

           i_date         = cur_date

           i_periv        = 'V0'

         IMPORTING

           e_buper        = buper

           e_gjahr        = gjahr

         EXCEPTIONS

           input_false    = 1

           t009_notfound  = 2

           t009b_notfound = 3

           OTHERS         = 4.

       IF sy-subrc <> 0.

       ELSE.

         CONCATENATE gjahr buper INTO l_s_range-low.

         l_s_range-sign 'I'.

         l_s_range-opt  'EQ'.

         APPEND l_s_range TO e_t_range.

anshu_lilhori
Active Contributor
0 Kudos

I still think lot of confusion is there.

So i will ask one simple question.What text you need to display in the header of particular column and how it needs to be derived.

Is it that you need to display the current month - 1 i.e Feb 2015 or whats the logic of deriving the same.

Forget about the variable you have in place.If you answer this then it would be easy for all of us to guide you.

Regards,

AL

sri_harsha2
Participant
0 Kudos

Anshu,

I need to display the Feb 2015 in header for that particular column..

This column has the data for previous month ( Feb 2015 ). This data is populated

because of the below restrictions.

Current query in production :

I need to display the previous Calender month ( Feb 2015) in the header text. This is the requirement.

anshu_lilhori
Active Contributor
0 Kudos

My suggestion would be if you just need to display the previous month text in header of a column then follow these steps:

Create one text variable processed by customer exit.

Write the code in i_step = 1.

Data: v_month(2)      TYPE n,

         zktx TYPE fcktx,

         ym(20) TYPE  c.

When 'VAR_TEXT'. --------------(Name of text variable)

v_month = sy-datum+4(2) - 1.

SELECT ktx FROM t247 INTO zktx WHERE spras = 'EN' AND mnr = v_month.

        ENDSELECT.

        CONCATENATE zktx '-' sy-datum(4) INTO ym.

        l_s_range-low = ym.

        l_s_range-opt = 'EQ'.

        l_s_range-sign = 'I'.

APPEND l_s_range TO e_t_range.

This shall give you the required heading.

Regards,

AL

Loed
Active Contributor
0 Kudos

Hi Sri,

If you only need to get the text of previous month of yesterday's date, do this..

data: yesterday_date like sy-datum,

        first_day like sy-datum,

        temp_date like sy-datum.

WHEN 'ZCALMOFY'.

yesterday_date = sy-datum - 1.

concatenate yesterday_date(6) '01' into first_day.

temp_date = first_day - 1.

      if temp_date+4(2) = '01'.

            concatenate 'Jan' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '02'.

            concatenate 'Feb' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '03'.

            concatenate 'Mar' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '04'.

            concatenate 'Apr' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '05'.

            concatenate 'May' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '06'.

            concatenate 'Jun' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '07'.

            concatenate 'Jul' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '08'.

            concatenate 'Aug' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '09'.

            concatenate 'Sep' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '10'.

            concatenate 'Oct' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '11'.

            concatenate 'Nov' temp_date(4) into l_s_range-low.

      elseif temp_date+4(2) = '12'.

            concatenate 'Dec' temp_date(4) into l_s_range-low.

      endif.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.

Regards,

Loed

sri_harsha2
Participant
0 Kudos

Hi Loed,

I tried using the replacement path in the beginning but it did not work. The requirement was the

text variable was showing up Feb 2014 ( Fiscal year 10/2014). As this was confusing to the

user, the user wanted to display it as Feb 2015 ( Calendar month/year). I tried using the

code above if that would show up the Calender month/year instead of Fiscal period/year. I believe

I am making some mistake in the code. Please find the query designer below

Loed
Active Contributor
0 Kudos

Hi Sri,

So in the input variable, user entered Feb 2015..So the value 0P_PRFP1 will be Feb 2014 since it's for the previous year? Is that right? If yes, replacement path will really not work..

What is your input variable? Is it coming from fiscal year/period or calmonth? May I see your filter section? If it is coming from calmonth, what is the name of the variable that you are using?

Try this, assuming that ZPFYPER is your input variable and it is the fiscal year/period:

WHEN 'ZCALMOFY'.

       READ TABLE i_t_var_range INTO loc_var_range WITH

       KEY vnam = 'ZPFYPER'.

       l_s_range-low = loc_var_range-low.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.



Or if you want the name in words, let's hard code it..


WHEN 'ZCALMOFY'.

       READ TABLE i_t_var_range INTO loc_var_range WITH

       KEY vnam = 'ZPFYPER'.

     if loc_var_range-low+5(2) = '01'.

            concatenate 'Jan' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '02'.

            concatenate 'Feb' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '03'.

            concatenate 'Mar' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '04'.

            concatenate 'Apr' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '05'.

            concatenate 'May' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '06'.

            concatenate 'Jun' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '07'.

            concatenate 'Jul' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '08'.

            concatenate 'Aug' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '09'.

            concatenate 'Sep' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '10'.

            concatenate 'Oct' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '11'.

            concatenate 'Nov' l_s_range-low(4) into l_s_range-low.

      elseif loc_var_range-low+5(2) = '12'.

            concatenate 'Dec' l_s_range-low(4) into l_s_range-low.

      endif.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.

Regards,

Loed

anshu_lilhori
Active Contributor
0 Kudos

I am really confused with your requirement but lets try to summarize what you are looking for.

The Current text is showing as Feb 2014 and you want it to display as Feb 2015.

The only thing you need to change is year right.

You created one text variable processed by customer exit -ZCALMOFY

One user input variable 'ZPFYPER' where user enters period and year.Now what user enters in the screen so that you get that above text.Can you please let me know.

As i do not have V0 variant defined in my system.

After this we can go forward.

Regards,

AL

sri_harsha2
Participant
0 Kudos

Hi Anshu,

Thanks for the reply. The requirement is that the text of the column is displayed in terms

of Fiscal period/ year and I want to it to be displayed as Calendar month / year. As you said from Feb 2014 to Feb 2015. The year has to be changed. This is would give a clear picture to the user.

As the report is broadcasted the user does not get the screen to give input variables. The restriction

is given as Previous Fiscal year the report is auto generated.

sri_harsha2
Participant
0 Kudos

Thank you Sander, Uma shankar. Sorry the above things were confusing, the code did not work

as expected. I have made changes to the code so that the Calendar month/year text would

be picked from the fiscal period/year. The text variable that I have changed now is to ZCALMOFY

currently I do not have issue with V0. this report is specifically run on the first day of every month.

This report would give the data for the previous month.

After modifying the code I am still not able to see the Calendar month/year ( Example currently: Feb 2014 ). Here is the code that I have used

WHEN 'ZCALMOFY'.

       READ TABLE i_t_var_range INTO loc_var_range WITH

       KEY vnam = 'ZPFYPER'.

       ld_fiscyear = loc_var_range-low(4).

       ld_poper1   = loc_var_range-low+4(3).

       CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'

         EXPORTING

           i_gjahr              = ld_fiscyear

             i_periv              = 'V0'

           i_poper              = ld_poper1

         IMPORTING

           e_date               = ld_fypdate

                 .

       IF sy-subrc <> 0.

       ENDIF.

       ld_calmonth = ld_fypdate(6).

       l_s_range-low = ld_calmonth.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'EQ'.

       APPEND l_s_range TO e_t_range.


I request you to advise me on this if I am making any mistakes in the code. Please find the

screenshot regarding the restrictions and output of the report.


Loed
Active Contributor
0 Kudos

Hi Sri,

What do you want to do? Is it the Text variable?

Why don't you use REPLACEMENT PATH instead of CUSTOMER EXIT?

Just link it to your FISCAL YEAR/PERIOD variable which is 0P_PRFP1..Did you already try this?

If you don't like this solution, can I see your query designer so we can suggest another solution..

Regards,

Loed

umashankar_poojar
Active Contributor
0 Kudos

Hi Sri harsha,

        Does T009B has entries for V0 which has all special periods listed? I guess T009B for V0 has values only for Period 01 to 12 and special periods (0,13,14,15,16) are not maintained.

        If you maintain the fiscal year variant for special periods, then it should work.

Thanks,

Umashankar

sander_vanwilligen
Active Contributor
0 Kudos

Hi,

Did I understand you correctly that the text variable is actually causing problems?

Please share a screenshot of how this text variable looks like.

Best regards,

Sander

sri_harsha2
Participant
0 Kudos

Thank you for your response. The issue is coming up when I tried to change the text variable. The text label should be displayed as previous Calendar month/year instead of Previous fiscal period. This was

the code in the customer exit I tried to use.

WHEN 'ZPRECALMNTH'.

READ TABLE i_t_var_range INTO loc_var_range WITH
KEY vnam = 'ZPFYPER'.

ld_fiscyear
= loc_var_range-low(4) - 1.
ld_poper1  
= loc_var_range-low+4(3).

CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
EXPORTING
i_gjahr             
= ld_fiscyeaR
i_periv             
= 'V0'
i_poper             
= ld_poper1

IMPORTING
e_date              
= ld_fypdate.

IF sy-subrc <> 0.
ENDIF.

ld_calmonth 
= ld_fypdate(6).
ld_CALYEAR
= ld_FISCYEAR(4).

SELECT SINGLE ktext FROM t009B
INTO ld_CALTEXT
WHERE periv = 'V0' AND
poper
= ld_poper1.

CONCATENATE ID_CALMONTH ld_CALYEAR
INTO ld_calTEXT SEPARATED BY space.


l_s_range
-low = ld_calmonth.
l_s_range
-sign = 'I'.
l_s_range
-opt = 'EQ'.
APPEND l_s_range TO e_t_range.


Please find the screenshot attached. The text label is in fiscal period. It should be displayed

as Feb 2015 ( Calendar month/year) instead of Feb 2014 ( 11/2014)



sander_vanwilligen
Active Contributor
0 Kudos

Hi,

I am afraid that I don't fully understand the issue yet. In the screenshot I can see text variable &ZT_FPER& and in the coding snapshot I can see variable ZPRECALMNTH. Which one are we talking about? Does it concern a text variable of type user-exit?

In the coding I found a few strange things. First of all table T009B does not have the field KTEXT in my SAP BW 7.31 system. Is this correct?

Then you determine the variable ID_CALMONTH. In the L_S_RANGE however, you are using again LD_CALMONTH. Shouldn't it be ID_CALMONTH?

Best regards,

Sander