cancel
Showing results for 
Search instead for 
Did you mean: 

Last fiscal year period

Former Member
0 Kudos
98

HI

I need to create a variable which will fetch me the data for last fiscal year

e.g, current month : 02.2014

it should fetch me the data for 02.2012 to 02.2013..

Any hints on how to write this logic in the customer exit?/

i can derive high value as below- but need help on how to define low value ?

    WHEN 'ZPYTD'.

      CLEAR: date_py.

      date_py = sy-datum - 365.

      l_s_range-high = date_py.

      l_s_range-sign = 'I'.

      l_s_range-opt  = 'BT'.

      APPEND l_s_range TO e_t_range.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

IS there a way to achieve this by on the basis of sy-datam.?

for eg..if i execute the report on 10 feb, it should give me the data for last fiscal year period  based on the sy-datum itself

like Output shou?ld be 10th feb 2012 to o th feb 2013..

anshu_lilhori
Active Contributor
0 Kudos

see two things you have  to decide:

  1. Whether you will have any user input variable or not ? or it will be derived based on system date.
  2. On which object you are trying to create the customer exit variable ? calday.calmonth or fiscper.

Please clarify.Based on these inputs code need to be amended,

Regards,

AL

Former Member
0 Kudos

Thanks for your replyy..please find answer as below-

1) basedon  system date only

2) 0FISCPER

anshu_lilhori
Active Contributor
0 Kudos

Please check this code out:


Data:MM(2) type n,

          fisc type bi0/oifiscper,

          fisc1 type bi0/oifiscper,

          zyear type /bi0/oicalyear,

          zyear1 type /bi0/oicalyear.

WHEN 'V2'.---Cmod variable

IF i_step = 2.


       CLEAR: l_s_range.


       zyear  = sy-datum(4) - 1.

       zyear1 = sy-datum(4) - 2.

       MM = sy-datum+4(2).

       CONCATENATE zyear '0' MM INTO fisc.

       CONCATENATE zyear1 '0' MM INTO fisc1.

       l_s_range-low = fisc1.

       l_s_range-high = fisc.

       l_s_range-sign = 'I'.

       l_s_range-opt = 'BT'.

        APPEND l_s_range TO e_t_range.

EXIT.

ENDIF.

Hope this helps.

Regards,

AL

Former Member
0 Kudos

Hi Pallavi,

You can make use of FM RST_TOBJ_SHIFT in your customer exit variable.

WHEN 'ZPYTD'.


CALL FUNCTION 'RST_TOBJ_SHIFT'

   EXPORTING

     I_TIMNM              = '0CALMONTH'

     I_TIMVL              = " Enter yout current cal month here in format 201402"

     I_SHIFT              = '24-'

   I_FISCVARNT          = "enter your fiscal year variant"

IMPORTING

  E_TIMVL              = l_s_range-low.

CALL FUNCTION 'RST_TOBJ_SHIFT'

   EXPORTING

     I_TIMNM              = '0CALMONTH'

     I_TIMVL              = " Enter yout current cal month here in format 201402"

     I_SHIFT              = '12-'

   I_FISCVARNT          = "enter your fiscal year variant"

IMPORTING

  E_TIMVL              = l_s_range-high.


      l_s_range-sign = 'I'.

      l_s_range-opt  = 'BT'.

      APPEND l_s_range TO e_t_range.

Hope this helps.

Regards,

Satyam

Former Member
0 Kudos

Hi,

I would prefer Anshu's solution to substracting 365 days logic. This logic fails when you come across Leap year.

most date calculations look simple however many solutions cover only 99% scenarios. 1% scenario will occur when u are totally unprepared.

Thanks and Regards,

A Prashant Kiran

arivazhagan_sivasamy
Active Contributor
0 Kudos

Hi Pallavi,

Can you write like below..

WHEN 'ZPYTD'.

      CLEAR: date_py.

      date_py = sy-datum - 365.

     

     date_pz = date_py - 365.


    

         

      l_s_range-low = date_pz. 

  

      l_s_range-high = date_py.

    

      l_s_range-sign = 'I'.

      l_s_range-opt  = 'BT'.

      APPEND l_s_range TO e_t_range.



Arivazhagan S

anshu_lilhori
Active Contributor
0 Kudos

Data:MM(2) type n,

          Month type /bi0/oicalmonth,

          Month1 type /bi0/oicalmonth,

         zyear type /bi0/oicalyear,

          zyear1 type /bi0/oicalyear.

WHEN 'V2'.---Cmod variable

IF i_step = 2.

       READ TABLE i_t_var_range INTO loc_var_range

       WITH KEY vnam = 'V1'.--User input variable

       CLEAR: l_s_range.

        if sy-subrc = 0.

       zyear  = loc_var_range-low+0(4) - 1 .

        zyear1 = loc_var_range-low+0(4) - 2 .

       MM = loc_var_range-low+4(2).

       CONCATENATE zyear MM INTO Month.

        CONCATENATE zyear1 MM INTO Month1.

        l_s_range-low = Month1.

         l_s_range-high = Month.

        l_s_range-sign = 'I'.

        l_s_range-opt = 'BT'.

        APPEND l_s_range TO e_t_range.

EXIT.

ENDIF.

EBDIF.

Hope this helps.

Regards,

AL