Skip to Content
author's profile photo Former Member
Former Member

functio module or how to get date based on the fiscal year and period

hi

i hve in selection screen data as fiscal year and period

eg 2007 fiscal year

and period 02 - 09

please let me know how to get date range based on this above parameters for fiscal year and period

regards

Arora

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 08:37 AM

    hi ERIC

    that code if fine but my problem is that if we select value of periv from t001 table it gets factory calander date

    i want general calaneder date whta is the value for generl calender date? can u pls suggest i will hard code that value for the functio moudle

    regards

    arora

    Add a comment
    10|10000 characters needed characters exceeded

    • OK, than it is simple:

      DATA : gv_year       TYPE gjahr,
             gv_month1     TYPE monat,
             gv_month2     TYPE monat,
             gv_date_start TYPE datum,
             gv_date_end   TYPE datum.
      
      gv_year = '2008'.
      gv_month1 = '01'.
      gv_month2 = '06'.
      
      CONCATENATE gv_year gv_month1 '01' INTO gv_date_start.
      
      IF gv_month2 = '12'.
        gv_month2 = '01'.
        gv_year = gv_year + 1.
      ELSE.
        gv_month2 = gv_month2 + 1.
      ENDIF.
      CONCATENATE gv_year gv_month2 '01' INTO gv_date_end.
      gv_date_end = gv_date_end - 1.

  • Posted on Jun 17, 2008 at 07:16 AM

    hi,

    you can use the following FMs:

    FIRST_DAY_IN_PERIOD_GET

    LAST_DAY_IN_PERIOD_GET

    to determine the first day of the opening period and the last day of the closing period, to have the range. You'll need the fiscal year variant of the company code as well.

    hope this helps

    ec

    Add a comment
    10|10000 characters needed characters exceeded

    • pls. see the following code:

      DATA : gv_year   TYPE gjahr,
             gv_month1 TYPE poper,  "start month
             gv_month2 TYPE poper,  "last month
             gv_periv  TYPE periv,
             gv_begin  TYPE datum,  "start day
             gv_end    TYPE datum,  "last day
             gv_bukrs  TYPE bukrs.
      
      SELECT SINGLE periv
             INTO gv_periv
             FROM t001
             WHERE bukrs EQ gv_bukrs.
      
      gv_year = '2008'.
      gv_month1 = '001'.
      gv_month2 = '006'.
      
      CALL FUNCTION 'FIRST_DAY_IN_PERIOD_GET'
        EXPORTING
          i_gjahr              = gv_year
      *   I_MONMIT             = 00
          i_periv              = gv_periv
          i_poper              = gv_month1
       IMPORTING
         e_date               = gv_begin
       EXCEPTIONS
         input_false          = 1
         t009_notfound        = 2
         t009b_notfound       = 3
         OTHERS               = 4.
      
      IF sy-subrc <> 0.
      * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      
      CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
        EXPORTING
          i_gjahr              = gv_year
      *   I_MONMIT             = 00
          i_periv              = gv_periv
          i_poper              = gv_month2
       IMPORTING
         e_date               = gv_end
       EXCEPTIONS
         input_false          = 1
         t009_notfound        = 2
         t009b_notfound       = 3
         OTHERS               = 4.
      
      IF sy-subrc <> 0.
      * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
      *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

  • author's profile photo Former Member
    Former Member
    Posted on Jun 17, 2008 at 10:53 AM

    hi Eric

    thanks for the full code i will use this code for testing purpose and let me testit i will come back to u tommarow ...

    regards

    Arora

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 18, 2008 at 09:47 AM

    hi Eric

    thanks a lot for the code actually i was also thinking for the some but was confused in the yeaer calculation the solution of which i found in ur code

    i suppose it should work fine let me test it i will revert bact if any question

    also i need to know the difference between the this code and the above function module code...what is the basic difference for using that function module we need to use that perive right?

    and that perive is based on the factory calender so this is the limitation of above funtion moudle right?

    thanks again for providing the simple solution 😊

    regards

    arora

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.