Function module for getting month and year of the previous month (say -6)

Hi,
Is there a function module that will get you the month and year of say, a month before, and as far as 11 months ago.
For example, say today is 6/2007. I want 7 months ago.
How do i get this value?
What function module or method is available?
Points will be rewarded and responses will be appreciated.
Thank You,
John

Hi
lv_period gives the month and year which is two months earlier now as we have specified lv_months as -2.
    DATA: LV_PERIOD LIKE S001-SPMON,
          LV_MONTHS(2) TYPE C VALUE '2-',
          LV_DATUM LIKE SY-DATUM,
          LV_NEWDT LIKE SY-DATUM,
        P_SPMON LIKE S001-SPMON VALUE '200601'.
    CONCATENATE P_SPMON '01' INTO LV_DATUM.
    LV_PERIOD = P_SPMON+0(6).
    CALL FUNCTION 'MONTH_PLUS_DETERMINE'
         EXPORTING
              MONTHS  = LV_MONTHS
              OLDDATE = LV_DATUM
        IMPORTING
             NEWDATE = LV_NEWDT
         EXCEPTIONS
              OTHERS  = 1.
     IF SY-SUBRC = 0.
       LV_PERIOD = LV_NEWDT+0(6).
     ENDIF.
WRITE :/ LV_PERIOD.
OR
Use the following FM for getting the year and the month based on date
CACS_DATE_GET_YEAR_MONTH
or
Call Function 'CCM_GO_BACK_MONTHS '.
Funny module: 03/31/2002 - 1 month = 02/31/2002
OR
RE_ADD_MONTH_TO_DATE ( Add / substract month to/from date )
Need ur reward points.
Best regards,
Ravi

Similar Messages

  • Function module to get 'Date one year in the past' in APO

    Hi,
    Required function module to get date one year in the past in APO.
    Thanks and regards,
    M.R.Reddy.

    Hi Reddy,
    Try these function modules
    /SAPAPO/DATE
    /SAPAPO/FISCAL_BDATE
    /SAPPO/MAPI_MAP_CREATDATE
    /SAPPO/MAPI_MAP_POSTDATE
    /SAPAPO/LCP_CALC_DATE
    /SAPAPO/VS_ORDER_GET_DATES
    /SAPAPO/PERIOD_CONVERT_DATE
    /SAPAPO/PERIOD_DATE_GET_FROMTO
    /SAPAPO/PERIOD_GET_DATE_RANGE
    /SAPAPO/PERIOD_GET_FOR_DATE
    /SAPAPO/PERIOD_GET_FROM_TODATE
    Regards
    R. Senthil Mareeswaran.

  • Required function module to get date one year in the past.

    Hi,
    Required function module to get date one year in the past.
    Thanks and regards,
    M.R.Reddy.

    Hello,
    You can check this:
    DATA:
    V_DATE1 TYPE D,
    V_DATE2 TYPE D.
    V_DATE1 = SY-DATUM.
    TRY.
        CALL METHOD CL_HRPAD_DATE_COMPUTATIONS=>SUBTRACT_YEARS_FROM_DATE
          EXPORTING
            START_DATE = V_DATE1
            YEARS      = 1
          RECEIVING
            DATE       = V_DATE2.
      CATCH CX_HRPA_VIOLATED_POSTCONDITION .
    ENDTRY.
    WRITE:
    / V_DATE1, / V_DATE2.
    Hope this helps.
    Br,
    Suhas

  • Function Module for Get Price  and Bonus in Sales Order

    Hi.. ABAP Guru's..
    I wanna make a function for get price and get Bonus for all material items in sales order.
    Help me for solving it.. Please.
    Thanks a lot before and after.
    Rgds,
    Asep Saepudin

    Hi,
       Welcome to SDN.
    Refer
    https://forums.sdn.sap.com/click.jspa?searchID=7085162&messageID=782207
    https://forums.sdn.sap.com/click.jspa?searchID=7085162&messageID=950526
    Regards

  • Useful function module for get month

    Dear experts,
    I need some FM to realise some functions :
    1, get the month and year from system date
    2, get the month by adding or subtracting from a given month ex: month(system date) - 11
    Moderator message: date conversion questions = FAQ, please search (harder) before asking.
    Edited by: Thomas Zloch on Nov 7, 2010 9:24 PM

    Hi
    I think you can find out the answer if you look for it in SDN forum: have you tried?
    Max

  • Any function module for getting fiscal year week numbers

    can any one provide me function module for getting fiscal year week numbers ? if no function module please let me know work around.
    Thanks!
    Lakshmikandh

    hi,
    Use FM <b>'DATE_GET_WEEK'</b>...
    parameter D1 LIKE SCAL-DATE.
    Data w like scal-week.
    CALL FUNCTION <b>'DATE_GET_WEEK'</b>
    EXPORTING
    date = D1
    IMPORTING
    WEEK = W
    EXCEPTIONS
    DATE_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.
    write W+4(2).
    Regards,
    Santosh

  • Function Module to get BEGIN and END date of a month?

    Hello everybody,
    Is there any function module to get BEGIN and END date of a month
    GIVEN EITHER THE CURRENT SYSTEM DATE or MONTH?
    Regards,
    Sanghamitra.A.

    hi
         CALL FUNCTION 'PA03_PERIODDATES_GET'
            EXPORTING
              f_abkrs               = p_abkrs1
            IMPORTING
              f_permo               = wf_permo
              f_current_begda       = wf_begda
              f_current_endda       = wf_endda
            CHANGING
              f_current_period      = wf_pabrp
              f_current_year        = wf_pabrj
            EXCEPTIONS
              pcr_does_not_exist    = 1
              abkrs_does_not_exist  = 2
              period_does_not_exist = 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.
    this is the function module to get the first date and last date of a particular month
    if u have any doubts ask
    regads
    karthik
    reward points if useful

  • Function Module for Start time and End time

    Hi Experts,
    I need a function module for getting particular Work schedule rule start time and endtime and further details by passing personnel number and day.
    Thanks in advance.
    Sunil

    FYI - https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=5338428
    Thanks,
    SK

  • Functional module for Getting Material classification data.

    Please tell me Functional module for Getting Material classification data like class type , class, characteristics and characteristics values for material.

    Dear,
    FM:
    CLAF_CLASSIFICATION_OF_OBJECTS
    Table KLAH Class Header Data
    - KSML Characteristics of a Class
    Regards,
    R.Brahmankar

  • Function module for calculating planned and actual cost of production order

    Hi ,
    Do we have any standard function module for calculating planned and actual cost for production order?
    i need to implement this in a Z-report.
    Thanks
    Srini

    Hi,
    try below function module
    CRMCO_GET_PLAN_ACTUAL_COSTS
    CO_IH_GET_PLANNED_COSTS_TOTAL
    Regards,
    Sankaran

  • Function Module for getting address from address number

    Hi all,
    Is there any function module for getting address from address number. kindly reply.
    regards,
    siya

    HI,
    just try this function module:
    CALL FUNCTION 'HR_GET_ADDRESS'
        EXPORTING
          ankey          = ankey
          anart          = anart
          molga          = '01'
        IMPORTING
          address_detail = adr_data
        EXCEPTIONS
          not_found      = 1
          OTHERS         = 2.
    HOPE IT WILL HELP YOU
    regards
    rahul

  • Is there any function module for getting distribution list name

    Hi all,
    Is there any function module for getting distribution list name when there is same description for two distribution list name.
    or
    help me how to fetch the correct distribution name when there is same description.
    In order to send mails.
    Tell me ASAP.
    thanks
    sagar.

    http://www.sapbrainsonline.com/REFERENCES/FunctionModules/SAP_function_modules_list.html
    list of Fms

  • Any Function Module For getting Shipment Details

    Hi All,
    I want to get all details of shipment. i tired , but unable to get any function? I was able to find the creation or change shipment function modules, but not able to find the function module for getting the details for Shipment.
    like BAPI_SHIPMENT_CHANGE           Change Shipment
    BAPI_SHIPMENT_CREATE           Create Shipment
    similary
    Do you have any idea for getting (display)the details of Shipments?
    Regards,
    Raju

    hi,
    you can use
    VTTP,VTTK
    or
    RV_SHIPMENT_READ

  • Calculating previous month and year of the previous month

    Hi frenz,
    Can anybody know FM to calculate the previous month and year of the previous month.
    are there any standard FMs existed to achieve this?
    br,
    anil.

    hi,
    lv_period gives the month and year which is two months earlier now as we have specified lv_months as -2.
        DATA: LV_PERIOD LIKE S001-SPMON,
              LV_MONTHS(2) TYPE C VALUE '2-',
              LV_DATUM LIKE SY-DATUM,
              LV_NEWDT LIKE SY-DATUM,
            P_SPMON LIKE S001-SPMON VALUE '200601'.
        CONCATENATE P_SPMON '01' INTO LV_DATUM.
        LV_PERIOD = P_SPMON+0(6).
        CALL FUNCTION 'MONTH_PLUS_DETERMINE'
             EXPORTING
                  MONTHS  = LV_MONTHS
                  OLDDATE = LV_DATUM
            IMPORTING
                 NEWDATE = LV_NEWDT
             EXCEPTIONS
                  OTHERS  = 1.
         IF SY-SUBRC = 0.
           LV_PERIOD = LV_NEWDT+0(6).
         ENDIF.
    WRITE :/ LV_PERIOD.
    Regards,
    Sailaja.

  • Functional module for 12 MONTHS AVERAGE SALARY

    hi all,
    I want to get the average salary for an employee for past 12 months from cluster tables. I believe the cluster table for that is PCL2? . I want to know the name of the function module to get the average salary for an employee for past 12 months from cluster tables. If anyone could explain me with help of the coding how to use that function module  - passing what all parameters, it would be great.
    I anyone have any custom report for extracting payroll data from cluster tables, Please let me know. Please share the coding. My e mail id is [email protected]

    Ribhu,
    You can retrieve the last payroll result for the year & read the YTD Gross (year-to-date) from the CRT table & divide by12 to get the Average Salary..
    ~Suresh

Maybe you are looking for

  • MacBook Pro mid 2009 won't boot OSX

    Since today i have a strange problem booting into Mac. This is how it started out: I was inside of Mac, and decided to reboot to Windows, to play a match of MW2. I forgot to use the ALT button, so Mac was already booting. I used the on/off switch to

  • WHy isn't itunes opening after uploading the newest software updates

    I installed the newest version of iTunes today, April 7, 2013, and now iTunes will not open at all on my PC.

  • When I click on some PDFs Preview advises that No such File exists in Preview V7.

    Sometimes when I go to open documents in Preview V7 under Mavericks I get a message that "The file "download.pdf" couldn't be opened because there is no such file" If I then click on OK button in the message the document opens.  Is this because of a

  • How do I know if spyware has been installed?

    Weird stuff is happening with my device.  No apps will be running and the audio recorder bar will be red and recording via autorap.  Background was changed while I showered the other morning.  Nobody in my home, was done remotely.  Battery drains qui

  • Album Art not displaying in iTunes

    I have several mp3s where the album art does not display in iTunes, it does, however, display when I use other software such as MediaMonkey or foobar2000.  The album artowork is stored in the tag.  I've tried retagging them within iTunes, but it does