cancel
Showing results for 
Search instead for 
Did you mean: 

previous fiscal year

Former Member
0 Kudos

I require previous fiscal year data for some kpi's.I have used standard sap provided customer exit(0FYEAR) and set the offset to -1.Its getting the data from previous fiscal year till date but i require data from previous fiscal year only.how should i proceed?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

Create a Exit Variable and write the below code under i_step = 2.

      WHEN 'ZFYEAR'.
      CLEAR: l_s_range.

      CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
        EXPORTING
          i_date   = sy-datum
          i_monmit = '00'
        IMPORTING
          e_buper  = wa_cur_period
          e_gjahr  = wa_fiscal_year.

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

Below code will populate current fiscal year. So please use offset -1 for previous fiscal year.

I'm doing the same in my current project.

Regards

Murthy

dheeraj_gupta5
Explorer
0 Kudos

In above code little modification in call function->

CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

        EXPORTING

          i_date   = sy-datum

          i_monmit = '00'

          I_PERIV = 'V1' " whatever fiscal year variant you want or derive from company code master data         IMPORTING

          e_buper  = wa_cur_period

          e_gjahr  = wa_fiscal_year.

Former Member
0 Kudos

Hi,

I am not unable to understand why it is not working for standard customer exit I have used -1 as the offset also.it should bring only previous year data,why it is bringing current year data also??

Former Member
0 Kudos

Hi ,

you have to write previous fiscal year exit .

Sample P fiscal Code :

PREVIOUS YR YTD

  WHEN 'ZC00000N5'.                 " Previous Year Till date
    IF i_step = 2 .


*      LOOP AT i_t_var_range INTO loc_var_range
*             WHERE vnam = 'ZC00000N1'.  "USER INPUT KEY DATE
      LOOP AT i_t_var_range INTO loc_var_range
        WHERE vnam = 'ZC00000N51'.        " USER INPUT KEY DATE (Report Date)
        CLEAR l_s_range.
        v_datef1 = loc_var_range-low .               
        v_datef1(4) = loc_var_range-low(4) - 1 .
        v_year_tmp = loc_var_range-low(4)  .       
        v_year_tmp =   v_year_tmp MOD 4 .
        IF  v_year_tmp  EQ 0  .
          IF loc_var_range-low+4(4) EQ '0229'  .
            v_datef1(4) = loc_var_range-low(4) - 1 .
            v_datef1+4(4) = loc_var_range-low+4(2) .
            v_datef1+6(2) = '28' .

          ELSE .
            v_datef1(4) = loc_var_range-low(4) - 1 .
            v_datef1+4(4) = loc_var_range-low+4(4) .
          ENDIF .                                         
        ENDIF .
*        v_datef1+4(4) = loc_var_range-low+4(4) .

*       TO CALCULATE FISCAL PERIOD YEAR .

        CALL FUNCTION 'UMC_CALDAY_TO_FISCPER'
          EXPORTING
            i_periv   = 'V3'
            i_calday  = v_datef1
          IMPORTING
            e_fiscper = v_per_day
          EXCEPTIONS
            invalid   = 1
            OTHERS    = 2.
        IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

        l_s_range-low(4) = v_per_day(4) .
        l_s_range-low+4(4) = '0401' .
        l_s_range-sign = 'I'.
        l_s_range-opt =  'BT'.
        l_s_range-high = v_datef1 .
        APPEND l_s_range TO e_t_range.
      ENDLOOP .
    ENDIF.

Above code based on report Date ( system date -1 ), It can be on system date . code can be changed , as you desire.

Regards,

Anand Mehrotra.