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

Function module for calculating diff between time

Hi All,

Is there any FM to check for the below requirement,

Here request is the time, I have to

1.cmp the time between two intervals and

2.the day(Whether Holiday).

If a request is made Local time (0TIME) between 10PM to 6AM

If a request is made on a Holiday.

Pts will be awarded.

Regards,

vinoth.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    Posted on Jan 11, 2007 at 06:52 AM

    Hi,

    check

    SRET_TIME_DIFF_GET

    SD_DATETIME_DIFFERENCE

    -


    santhosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 06:52 AM

    CCU_TIMESTAMP_DIFFERENCE

    Have a look at below link.

    function-module

    I hope it helps.

    Best Regards,

    Vibha

    *Please mark all the helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 06:54 AM

    hi,,

    check the below link may be useful for you

    function-module-to-find-time-difference

    ~~Guduri

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 11, 2007 at 06:55 AM

    HI,

    check the fm below for your requirments.

    <b>1. SCOV_TIME_DIFF_46B

    2. DATE_CHECK_PLAUSIBILITY</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 06:55 AM

    try this

    DELTA_TIME_DAY_HOUR

    SD_DATETIME_DIFFERENCE

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 06:59 AM

    hi,

    these are some function modules that u could make use of.

    <b>

    L_MC_TIME_DIFFERENCE

    HR_PDC_CALCULATE_TIME_DIFF

    SRET_TIME_DIFF_GET

    SD_DATETIME_DIFFERENCE</b>

    if the answer solves ur problem do reward points.

    Regards,

    Kiran

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 07:02 AM

    Hi

    for first case use

    SD_DATETIME_DIFFERENCE

    for second one use

    BKK_CHECK_HOLIDAY

    Thanks

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 07:46 AM

    Hi vinoth ..

    See u r looking for the time interval to be

    checked between the interval 220000 hrs (10 pm

    ) to 060000hrs ( 6 am ) of next day ..

    Then why are you calculating the difference? is

    it for a shift timing check ..

    to get the diff " but im sure u may not require this ..

    data:DATE_FROM LIKE  LTAK-BDATU,
           DATE_TO   LIKE  LTAK-BDATU,
           TIME_FROM LIKE  LTAK-BZEIT,
           TIME_TO LIKE  LTAK-BZEIT,
           DELTA_TIME LIKE  MCWMIT-BE_AE,
           DELTA_UNIT LIKE  MCWMIT-LZEIT.
    
    
           DATE_FROM = SY-DATUM.
           DATE_TO   = DATE_FROM + 1.
           TIME_FROM = '220000'.   
           TIME_TO   = '060000'.
    
           CALL FUNCTION 'L_MC_TIME_DIFFERENCE'
             EXPORTING
               date_from             = DATE_FROM
               date_to               = DATE_TO
              TIME_FROM             =  TIME_FROM
              TIME_TO               =  TIME_TO
            IMPORTING
              DELTA_TIME            = DELTA_TIME
              DELTA_UNIT            = DELTA_UNIT
            EXCEPTIONS
              FROM_GREATER_TO       = 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:/ DELTA_TIME , DELTA_UNIT.

    2. to check //If a request is made Local time (0TIME) between 10PM to 6AM

    you can use this logic..

    DATA : VAL LIKE SY-UZEIT.
    
    VAL = SY-UZEIT. " if u have this
    
    IF VAL BETWEEN TIME_FROM AND '240000' OR 
    VAL  BETWEEN '000000' AND TIME_TO.
    WRITE:/ 'IN THE INTERVAL'.
    ELSE .
    WRITE:/ 'NOT IN THE INTERVAL'.
    ENDIF.

    3. to check for a holiday ..use this

    *CHECK HOLIDAY

    data: ld_date                 like scal-date  ,
          lc_holiday_cal_id       like scal-hcalid ,
          ltab_holiday_attributes like thol occurs 0 with header line,
          lc_holiday_found        like scal-indicator.
    
    ld_date = sy-datum.
    lc_holiday_cal_id  = 'US'.
    
    CALL FUNCTION 'HOLIDAY_CHECK_AND_GET_INFO'
      EXPORTING
        date                               = ld_date
        holiday_calendar_id                = lc_holiday_cal_id
        WITH_HOLIDAY_ATTRIBUTES            = 'X'
      IMPORTING
        HOLIDAY_FOUND                      = lc_holiday_found
      tables
        holiday_attributes                 = ltab_holiday_attributes
      EXCEPTIONS
        CALENDAR_BUFFER_NOT_LOADABLE       = 1
        DATE_AFTER_RANGE                   = 2
        DATE_BEFORE_RANGE                  = 3
        DATE_INVALID                       = 4
        HOLIDAY_CALENDAR_ID_MISSING        = 5
        HOLIDAY_CALENDAR_NOT_FOUND         = 6
        OTHERS                             = 7.
    
    if sy-subrc = 0 and
       lc_holiday_found = 'X'.
      write: / ld_date, 'is a holiday'.
    else.
      write: / ld_date, 'is not a holiday.
    endif.

    you can calculate the diff if u want to but in my opinion you are looking for the time interval to fall in hte range for this u need to manipulate the logic cause 10pm to 6am is the date cuts twice and u need to take care of that .

    execute logic 1 and 2 and see how this can be done to check whether the time was in that interval .

    to check the holiday

    holiday_calendar_id = lc_holiday_cal_id

    make sure that u have this entry for the plant in t006w for calender id or

    tfacd table . an entry for the plant and the country has to be there before trying to find holiday.

    regards,

    vijay

    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.