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

Function modules for the following

Hi,

I want to know the function modules for the following purposes.

1) Check whether a date is valid or not

2) Calculate the no of days between two dates.

Expecting an early response.

Thanks n Regards,

Amit

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Posted on Jun 02, 2005 at 07:00 AM

    This is a valid statement in ABAP:

    num_of_days = date1 - date2.

    Where date1 and date2 are of type d.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 02, 2005 at 07:02 AM

    Hi,

    1) fm DATE_CHECK_PLAUSIBILITY

    regards Andreas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 02, 2005 at 07:10 AM

    Hi Amit,

    try this FM 'FIMA_DAYS_AND_MONTHS_AND_YEARS' to find

    difference between two dates.

    Regards,

    Narinder Hartala

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 02, 2005 at 07:59 AM

    Hi,

    PARAMETERS: p_list LIKE t009b-bumon AS LISTBOX

    VISIBLE LENGTH 11 OBLIGATORY ,

    p_list1 LIKE t009b-bdatj OBLIGATORY.

    SELECTION-SCREEN POSITION POS_HIGH.

    PARAMETERS: p_list2 LIKE t009b-bumon AS LISTBOX

    VISIBLE LENGTH 11 OBLIGATORY,

    p_list3 LIKE t009b-bdatj OBLIGATORY.

    • Calling Function Module for calculating no of days between the

    • selected period

    *----


    CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'

    EXPORTING

    par_month = p_list

    par_year = p_list1

    IMPORTING

    par_days = ws_n_days.

    CALL FUNCTION 'NUMBER_OF_DAYS_PER_MONTH_GET'

    EXPORTING

    par_month = p_list2

    par_year = p_list3

    IMPORTING

    par_days = ws_n_days1.

    *----


    • For Concatenating the month and year into the date format

    *----


    CONCATENATE p_list1 p_list ws_i INTO ws_c_date1.

    CONCATENATE p_list3 p_list2 ws_n_days1 INTO ws_c_date2.

    date = ws_c_date1 - ws_c_date2.

    In the above sample code the selection screen has month and year as input.

    Also check this link

    http://www.sapdevelopment.co.uk/tips/date/datehome.htm

    Check FM

    <b>RP_CALC_DATE_IN_INTERVAL</b> Add/subtract years/months/days from a date

    <b>SD_DATETIME_DIFFERENCE</b> Give the difference in Days and Time for 2 dates

    <b>Also for checking valid date:</b>

    U can specify the date field as

    Select-options: s_date like likp-date(similar to ur requirement)

    This itself ceck for the valid date no seperate validation needed.

    Thanks & Regards,

    Judith.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 02, 2005 at 10:02 AM

    Hello Amit,

    1.You can check the validity of the dates by using the FM DATE_CHECK_PLAUSIBILITY.

    2. Regarding the calculation of the num,ber of days between two dates i use the FM BCA_US_DATES_CALC_UNIT.

    Here is the sample code for the same.

    CALL FUNCTION 'BCA_US_DATES_CALC_UNIT'

    EXPORTING

    i_start_date = lv_date1

    i_end_date = lv_date2

    i_periodunit = '1'

    IMPORTING

    e_return = lv_date_diff.

    IF sy-subrc <> 0.

    ENDIF.

    Regards, Debasish

    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.