Need function modules for date manupulation

HI,
Could you please suggest the function module the below reqiurments
1) adding days to date.
ex: 20 days to 25.03.2008 = 15.04.2008
2) To find the given date is working date or not according to factory calender id.
3) To find the previous or last working date to the given date(Holiday date) according to the factory calender id.
It is very urgent requirment. please help me.
Thanks in advance
sathish kumar swamy

hi use this...
RE_ADD_MONTH_TO_DATE
DATE_CONVERT_TO_FACTORYDATE
CALL FUNCTION 'OIL_LAST_DAY_OF_PREVIOUS_MONTH'
     EXPORTING
          I_DATE_OLD = date1
    IMPORTING
         E_DATE_NEW = date1
data date2 like sy-datum.
date2 = date1 + 1.
write date2.
If you put 27.12.2005 as the input date,   date2 you will get as 01.12.2005.
Or else you can use the following code:
v_startdate = sy-datum.
v_startdate+6(2) = '01'.
v_enddate = v_startdate.
if v_enddate+4(2) >= '01' AND v_enddate >= '11'.
   v_endate4(2) = v_enddate4(2) + 1.
elseif v_enddate = '12'.
  v_enddate+4(2) = '01'.
  v_enddate(4) = v_enddate(4) + 1.
endif.
v_enddate = v_enddate - 1.
regards,
venkat.

Similar Messages

  • Function Modules for Data and Time

    Hi all,
              I need 2 function modules for date and time. when we pass current data(sy-datum) and current time (sy-uzeit) into function modules, shoud get date in <b>dd/mm/yyyy or dd.mm.yyyy</b> and time in<b> HH:MM:SS</b> formats.
    Thanks in advance

    Hi Ranjith,
    i think this will b usefull for you..
    SAP Bar Chart Function Modules and what they are used for
    Function module
    Used for
    BARC_GRAPHIC_PBO
    Starting bar chart at PBO time, using a graphic profile (parameter PROFILE)
    BARC_GRAPHIC_PAI
    Analyzing data returned by the graphic
    BARC_SET_TIME_AXIS
    Setting start and end of time axis
    BARC_SET_OPTIONS
    Setting options
    BARC_ADD_CHART
    Creating a chart
    BARC_SET_CHART_ATTRIB
    Setting chart attributes
    BARC_ADD_SECTION
    Creating a section on the time axis
    BARC_SET_SECTION_ATTRIB
    Setting section attributes
    BARC_ADD_RIBBON
    Adding a ribbon to the time axis
    BARC_SET_RIBBON_ATTRIB
    Setting attributes for ribbons in the chart
    BARC_ADD_GRID
    Adding a time grid
    BARC_SET_GRID_ATTRIB
    Setting grid attributes
    BARC_ADD_LAYER
    Adding a layer (graphic elements)
    BARC_SET_LAYER_ATTRIB
    Setting layer attributes
    BARC_ADD_LINE
    Adding a line
    BARC_ADD_CALENDAR
    Creating a calendar
    BARC_SET_CALENDAR_ATTRIB
    Setting attributes for a calendar
    BARC_ADD_TIME_PROFILE
    Creating time profiles
    BARC_SET_TIME_PROFILE_ATTRIB
    Setting attributes for time profile
    BARC_ADD_INTERVAL
    Adding a time interval
    BARC_SET_INTERVAL_ATTRIB
    Setting time interval attributes
    BARC_ADD_TIME_OBJECT
    Creating a time object
    BARC_CONVERT_DATE
    Creating a date string in bar chart format
    BARC_REVERT_DATE
    Converting a date string in bar chart format to date and time
    BARC_ADD_DATELINE
    Creating a date line
    BARC_SET_DATELINE_ATTRIB
    Setting dateline attributes
    BARC_GET_PROFILE_CONTENTS
    Obtaining profile contents for customizing a chart
    BARC_GET_COLUMN_WIDTH
    Selecting new column width
    BARC_SET_COLUMN_WIDTH
    Setting the column width
    BARC_GET_TEXTINDEX
    Obtaining the text index of a field
    BARC_SET_LABELS
    Positioning the chart display
    BARC_SET_COLUMN_ATTRIB
    Setting column attributes
    BARC_SET_ROW_ATTRIB
    Setting row attributes
    BARC_SET_ROW_HEIGHT
    Setting the line height
    BARC_SET_MAXCHARTS
    Setting the maximum number of charts sent
    <b>If its usefull reward points
    </b>

  • Need Function Module for convertion of  Foreign currency to Indian currency

    hi friends,
    i need function module for converting amount from
    Foreign currency to Indian currency
    thanks

    hi Venkat,
    Please use the function module CONVERT_TO_LOCAL_CURRENCY
    <b><u>Sample code:</u></b>
          call function 'CONVERT_TO_LOCAL_CURRENCY'
            exporting
              date             = p_alv_tab-begda
              foreign_amount   = p_alv_tab-kkost_p_person
              foreign_currency = p_alv_tab-kwaer                 " foreign currency
              local_currency   = l_ev_waer                           " Indian currency
            importing
              local_amount     = p_alv_tab-kkost_p_person
            exceptions
              no_rate_found    = 1
              overflow         = 2
              no_factors_found = 3
              no_spread_found  = 4
              others           = 5.
    Hope this helps,
    Sajan Joseph.

  • Function Module for data retrival for work order clearence (WCA)

    Hi All ,
      Function Module for data retrival for work order clearence (WCA) for a particular Planning plant and (WCD's).
    Thanks.

    Hi Anne,
    BAPI_PRODORD_GET_DETAIL
    BAPI_PRODORD_GET_LIST
    You can find further FM in Function Group COPRINT and CODR or take F4 on CO* in Function Group
    These will serve your purpose.
    Cheerz.
    Ram

  • Any Function module for Date conversion

    Hi,
    In my output the date is coming like 80999898 but the actual date is 01.01.1900.
    Could you please tell me is there any Function module for that.
    Regards,
    Tushar

    Use the conv. exit CONVERSION_EXIT_INVDT_OUTPUT for this purpose.
    BR,
    Suhas

  • Function modules for data retrieval from diff. tables

    Hi,
    I would just like to ask if there are function modules that can be used to retrieve data from the ff. tables:
    TSAD3T
    KNVV
    ESTRH
    for TSAD3T i need to get the value of title_medi
    for KNVV    i need to get the fields klabc vkorg vtweg
    for ESTRH  i need to get the fields subcat subid.
    Thanks.

    I doubt if you have such a FM

  • Function module for date

    Hello experts.
    my requirement is , I am having a fiscial year ( gjahr) and period ie month (monart) . Now i need afunction module that gives the last date of the month. say if it is january it should give 31 - month-year. I want to populate this date to the budat field. so please tell me how to solve this issue. i want to pass as date-month-year to budat. but i am having year as seperate field and month as seperate field. so please tell me the function module that gives all the three or any other solution to this.
    thanks for all the replies

    populate month, year u have and 01 into w_datum in and it should always give day1 of that month like this.
    concatenate l_year l_month '01' into w_datum_in.
    CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
                EXPORTING
                  day_in            = w_datum_in
                IMPORTING
                  last_day_of_month = w_datum_out
                EXCEPTIONS
                  day_in_not_valid  = 1
                  OTHERS            = 2.
    *reward if solved*

  • Function Module for Date/ Time difference in Working Days

    Hi all,
    Are there any function modules which will calculate the difference between a date AND time, but in working days?
    I can use the FIMA_DAYS_BETWEEN_TWO_DATES_2 FM for the dates, but I need to include times in this as well.
    This is for situations where the 'starting date' is a non-working day, and the 'end date' is a working day.  In this situation I need to take all the hours and minutes into account, which happened on the working day.  To give an example -
    Start date:  04.07.2010 (Sunday - Non working day)
    Start time:  21:12:36
    End date:  05.07.2010 (Monday - Working day)
    End time:  04:47:24
    I realise there is a Time option in this function module, but when I test it, it doesn't seem to be returning the desired results (returns 0 for days and time).  I am using '5' as the I_STGMETH and 'GB' as the I_SKALID. 
    I need a calcuation which will return the time, post midnight on the working day - in this example, 4 hours, 47 minutes (seconds are optional!).
    Can anyone help? - can I still use FIMA_DAYS_BETWEEN_TWO_DATES_2 but with different parameters?
    Thanks
    Mischa
    Edited by: Mischa Gulseven on Jul 20, 2010 10:40 AM

    Hi,
    Thanks but this FM does not seem to account for working days.
    For example, if I use:
    DATE1                           04.07.2010  (non working day)
    TIME1                           04:00:00
    DATE2                           05.07.2010   (working day)
    TIME2                           21:00:00
    It will give the following results -
    DATEDIFF                                                      1
    TIMEDIFF                                                     17
    EARLIEST                        1
    I don't want to account for the non-working day so the result I actually want would be to calculate from midnight on 05.07 to 21:00 on 05.07 which should be 21 hours.
    I suspect I probably need to include the STGMETH and the factory calendar somewhere in the FM?
    Does such a FM exist, or could anyone help me with some ABAP for this?
    thanks
    Mischa

  • Function Module for DATE Conversion

    Hi All,
    I need some help to know a function module to get the exact date in a year.
    If i give the no. of days and the year.. it has to give me the exact date.
    for eg: if no. of days are 90 and the year is 2006 the output should be 31st MARCH 2006. Like that if i enter any number (< 364 or 363) and the year it has to tell me the date of the count of no.of days.
    Thank You,
    Suresh

    Hi Suresh,
    You can use FM HR_SEN_CALE_DAYS_DATE.
    Here you can pass '01.01.2006' , operator as '+' and in
    IS_DURATION enter the number of days under 'CALDD'.
    For eg:
    Test for function group      HRSEN00CRULE_CALE_DAYS                              
    Function module              HR_SEN_CALE_DAYS_DATE                               
    Import parameters                                                                               
    ID_DATE                         01.01.2006  
      ID_OPERATOR                     +             
      IS_DURATION                         0.0000     0.0000       30.0000                                                                               
    Export parameters               Value                                                                               
    ED_DATE                         30.01.2006                                                                               
    Regards,
    Raj

  • Function Module for Date Conversion - 20060131 - January 31, 2006

    I can write some quick code and use the T015M table, but I figure there must be an existing function module.  I want to convert a system date to a character string.  Ideally, I would like it based on a country field.
    20060131 -> January 31, 2006
    20060131 -> 31 January 2006

    Norman
    Strange I've used edit mask LDATE, function CONVERSION_EXIT_LDATE_OUTPUT, and get the full month name.
    Anyway, here is a little program to see the outputs for different countries. It does need updating for edit mask MODAT, and checking the return code after select and function calls:
    REPORT ZZMATTG004 .
    DATA: D8(20),
          WA_MASK LIKE DD01D-CONVEXIT,
          MONTH_NAMES LIKE T247 OCCURS 12 WITH HEADER LINE.
    TABLES: T005.                          "Countries
    PARAMETERS: DATE LIKE SY-DATUM DEFAULT SY-DATLO.
    SELECT-OPTIONS S_LAND FOR T005-LAND1 NO INTERVALS.
    PARAMETERS: P_LANGU AS CHECKBOX DEFAULT 'X'.
    D8  =  DATE.
    DESCRIBE FIELD DATE EDIT MASK WA_MASK.
    WRITE: 'MASK IS :- ''', WA_MASK NO-GAP, '''' NO-GAP.
    SKIP.
    WRITE:
           / DATE DD/MM/YYYY, 22 'DD/MM/YYYY',
           / DATE MM/DD/YYYY, 22 'MM/DD/YYYY',
           / DATE DD/MM/YY  , 22 'DD/MM/YY',
           / DATE MM/DD/YY  , 22 'MM/DD/YY',
           / DATE DDMMYY    , 22 'DDMMYY',
           / DATE MMDDYY    , 22 'MMDDYY',
           / DATE YYMMDD    , 22 'YYMMDD'.
    SKIP.
    WRITE:
           / D8   USING EDIT MASK '==LDATE', 'LDATE',
           / D8   USING EDIT MASK '==SDATE', 'SDATE',
           / D8   USING EDIT MASK '==IDATE', 'IDATE',
           / D8   USING EDIT MASK '==D3DAT', 'D3DAT',
           / D8   USING EDIT MASK '==PDATE', 'PDATE',
           / D8   USING EDIT MASK '==INVD1', 'INVD1',
           / D8   USING EDIT MASK '==INVDT', 'INVDT'.
    LOOP AT S_LAND.
    * BREAK-POINT.
      SET COUNTRY S_LAND-LOW.
      SELECT SINGLE SPRAS INTO T005-SPRAS FROM T005
             WHERE  LAND1  =  S_LAND-LOW.
      IF  P_LANGU  =  'X'.
        SET LANGUAGE T005-SPRAS.
      ENDIF.
      REFRESH MONTH_NAMES.
      CALL FUNCTION 'MONTH_NAMES_GET'
           EXPORTING
                LANGUAGE              = T005-SPRAS
    *      IMPORTING
    *           RETURN_CODE           =
           TABLES
                MONTH_NAMES           = MONTH_NAMES
           EXCEPTIONS
                MONTH_NAMES_NOT_FOUND = 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.
    * READ TABLE MONTH_NAMES INDEX DATE+4(2).
      READ TABLE MONTH_NAMES WITH KEY MNR  =  DATE+4(2).
      SKIP.
      WRITE: / 'COUNTRY SET TO', S_LAND-LOW COLOR 2,
             / 'Month name is', MONTH_NAMES-KTX, MONTH_NAMES-LTX,
               'Language (T005) is', T005-SPRAS, '(SYST)', SY-LANGU.
      WRITE:
             / DATE DD/MM/YYYY, 22 'DD/MM/YYYY',
             / DATE MM/DD/YYYY, 22 'MM/DD/YYYY',
             / DATE DD/MM/YY  , 22 'DD/MM/YY',
             / DATE MM/DD/YY  , 22 'MM/DD/YY',
             / DATE DDMMYY    , 22 'DDMMYY',
             / DATE MMDDYY    , 22 'MMDDYY',
             / DATE YYMMDD    , 22 'YYMMDD'.
      SKIP.
      WRITE:
             / D8   USING EDIT MASK '==LDATE', 'LDATE',
             / D8   USING EDIT MASK '==SDATE', 'SDATE',
             / D8   USING EDIT MASK '==IDATE', 'IDATE',
             / D8   USING EDIT MASK '==D3DAT', 'D3DAT',
             / D8   USING EDIT MASK '==PDATE', 'PDATE',
             / D8   USING EDIT MASK '==INVD1', 'INVD1',
             / D8   USING EDIT MASK '==INVDT', 'INVDT'.
    ENDLOOP.
    SET COUNTRY SPACE.
    * SET LANGUAGE T005-SPRAS.
      REFRESH MONTH_NAMES.
      CALL FUNCTION 'MONTH_NAMES_GET'
           EXPORTING
                LANGUAGE              = SY-LANGU
    *      IMPORTING
    *           RETURN_CODE           =
           TABLES
                MONTH_NAMES           = MONTH_NAMES
           EXCEPTIONS
                MONTH_NAMES_NOT_FOUND = 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.
    * READ TABLE MONTH_NAMES INDEX DATE+4(2).
      READ TABLE MONTH_NAMES WITH KEY MNR  =  DATE+4(2).
      SKIP.
      WRITE: / 'COUNTRY SET TO', 'SPACE'    COLOR 2,
             / 'Month name is', MONTH_NAMES-KTX, MONTH_NAMES-LTX.
      WRITE:
             / DATE DD/MM/YYYY, 22 'DD/MM/YYYY',
             / DATE MM/DD/YYYY, 22 'MM/DD/YYYY',
             / DATE DD/MM/YY  , 22 'DD/MM/YY',
             / DATE MM/DD/YY  , 22 'MM/DD/YY',
             / DATE DDMMYY    , 22 'DDMMYY',
             / DATE MMDDYY    , 22 'MMDDYY',
             / DATE YYMMDD    , 22 'YYMMDD'.
      SKIP.
      WRITE:
             / D8   USING EDIT MASK '==LDATE', 'LDATE',
             / D8   USING EDIT MASK '==SDATE', 'SDATE',
             / D8   USING EDIT MASK '==IDATE', 'IDATE',
             / D8   USING EDIT MASK '==D3DAT', 'D3DAT',
             / D8   USING EDIT MASK '==PDATE', 'PDATE',
             / D8   USING EDIT MASK '==INVD1', 'INVD1',
             / D8   USING EDIT MASK '==INVDT', 'INVDT'.
    MattG.

  • Need Function Module for Printing Rates,Discounts and Taxes in Invoice.

    Hi All,
    For our Invoice printing I need to get a function module which will provide me the rates,discounts and taxes against each item line of the Invoice No.
    Finall it will be printed accordingly.
    Can anyone help me regarding this with input parameter example.
    Thx in Adv.

    Hi,
    As far as I know there is no fun module to print all this stuff.
    You have to get this data from KONV table by passing the VBRK table KNUMV field.
    Then check for all the Rates and amount KBETR and KWERT fields for the respective condition Types.
    You have to loop the KONV internal table and write all the condition rates and amounts in the script driver program.
    see any Std script for this.
    Regards,
    Anji

  • Need function modules for the following...

    Hello experts,
    Is there an function module that I can use for:
    1. get the last date for a given year
    2. get the exchange rate for a given document number in a span of 5 years -
    for example, I need to get the exchange rate of doc. number 0000000123
    for the year 2000, 2001, 2002, 2003, 2004 and 2005(maximum of 5 years)   
    Help would be greatly appreciated.
    Again, thank you guys and take care!

    Hi,
    To use CALCULATE_EXCHANGE_RATE_N, you just have to pass the required parameters like foreign amount/currency and local amount/currency, instead you can query the table TCURR for the same data, remember to convert the 'DATE' to internal format before sending it in to the fm/table, you can refer the following code, this might help,
    WRITE  V_date TO  LV_DATUM USING EDIT MASK '__.__.____'.
         CALL FUNCTION 'CONVERSION_EXIT_INVDT_INPUT'
           EXPORTING
             INPUT         = LV_DATUM
          IMPORTING
            OUTPUT        = LV_DATUM.
    Retrieve the Exchange rate from Custom table for the Exchange
            select ukurs from tcurr
            into tcurr-ukurs
            up to 1 rows
            where kurst = 'M'
            and   fcurr = komk-waerk
            and   tcurr = komk-HWAER
            and   gdatu >= LV_DATUM.
            endselect.
    Rgds,

  • Need functional module for service order

    hello,
    while creating service notification i want to create service order automatically.for that i need a functional module which is the key funtion to process creation of transaction in the background. i want the name of that functional module to create iw31 service order automatically  and that of functional group so that i can assign in the action box.
    Regards,
    Rajesh Kumar Raju
    9900311069

    Hi,
    unfortunately there is no such "official" BAPI available - not even in ERP2005! There is a BAPI called BAPI_ALM_ORDER_MAINTAIN but this is for changing an already existing service order.
    But, you can use what the "SAP CRM group" developed for their integration to the backend R/3 system. This FM is called CRM_CS_API_ORDER_CREATE and is part of FUGR CRM_CS_API_ORDER. This FM is acting in the same way as a "normal" BAPI although you can not find this FM in transaction BAPI.
    Hope this can help!
    Best regards, Johan

  • Function Modules for Date

    Hi ALL,
    I would like to know the various function modules that can be used for calculating dates.Like first day of month,last day.....etc etc.
    Please give me a list of the FM's and not the F4 help option info.
    Cheers

    Hi ,
    Here are a few FM used for date manipulation
    <b>DATE_IN_FUTURE  </b>                   Add / Substract days from a given date
    <b>HR_SGPBS_ADD_TIME_TO_DATE</b>     Find the next date based on input date , addition / sub and month , year ,date
    <b>CONVERT_DATE_TO_EXTERNAL</b>     Convert date to External format
    <b>SG_PS_ADD_MONTH_TO_DATE</b>     Find the next date based on input date , addition / sub and month , year ,date
    <b>DATE_COMPUTE_DATE</b>     For a input date gives the day of the week
    <b>DATE_GET_WEEK</b>For an input date ,gives the week as output
    <b>WEEK_GET_FIRST_DAY</b>     Input year and week output is the first day of the week
    <b>WEEKDAY_GET</b>     Gives the day range , Monday , Tuesday ,…..
    <b>RP_CALC_DATE_IN_INTERVAL</b>     Calculate Future Date
    <b>CALCULATE_DATE</b>     Calculate Future Date
    <b>FIMA_DAYS_AND_MONTHS_AND_YEARS</b>     Difference between two dates
    <b>CONVERSION_EXIT_PDATE_INPUT</b>     It checks if the date is in future , if yes an error is displayed
    Reagrds
    Arun

  • Function module for date ranges

    Hi all,
           Is there any function module to display all the dates in between start date and end date. Or provide blocke code for this.
    Ex : If i have given nov 5th 2008 and nov 10th 2008 as input parameters.
           Output should be nov 5th 2008, nov 6th 2008,nov 7th 2008,nov 8th 2008,nov 9th 2008,nov 10th 2008,
    Please help me out in this regard.
    thanks
    naidu

    Hi Omkaram,
           Thank you verymuch for your code. That link is useful for me. I have rewarded you.
           But when i'm using the same code in my function module its not working.
           I have done the debugging the function module is not taking the input.
          Ex : itab[] = lt_date[].
          when i'm doing debugging the input parameter lt_date has no value.
          I dont know why it is.
          Can you help me please.
       Regards
       Naidu

Maybe you are looking for

  • Error while retreving Oracle object from jdbc

    Iam getting following when my java code is trying to pass an object to oracle stored procedure which needs an object IN parameter Can someone please advise what would the reason for this problem. sql error ORA-06550: line 1, column 13: PLS-00201: ide

  • Web Services spontaneous turning off on Color LaserJet CM4540 MFP

    We are using ePrint on four seperate Color LaserJet CM4540 Multifunction printers in a business environment where we elected to activate ePrint in order to allow wireless printing for our iPhone and iPad users. We were able to set it up and get it wo

  • Redirecting

    Hi just a quick question, how do I redirect to another .jsp page. So, my page does something with a database, and say after 5 secs or so i want it to redirect to another page. how do I do that?

  • Wireless USB Dongle

    What is the best Wireless USB Dongle on the market that is compatible with the BT Home Hub 20.0? - I have a remote desktop PC in a beroom upstairs and the HH2.0 Iis downstairs.

  • Mail not handling Fonts correctly?

    Hi all. For some reason whenever I send mail to someone using Outlook, on there side it changes my default font to something else. I notice this when they respond, it different then what I have it set as. Any ideas? Is it something Outlook is doing?