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

Code for the the previous Sat and Sat four weeks prior based on todays date

Hi All...

I am looking for a bit of code to work out the following in a variable customer exit...)

Based on system (todays) date calculate the actual calendar day for

1. the last previous Saturday

2. the Saturday 4 weeks prior to 1.

i.e todays date is for instance 12th September 2011 then results code needs to produce is

1. 10/09/2011

2. 13/08/2011

Thanks in advance,

Steve;)

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 13, 2011 at 08:22 AM

    Hi Steve,

    You can follow the logic below:

    data: 
    l_date like sy-datum, **TODAY
    l_date2 like sy-datum, **First Saturday
    l_date3 like sy-datum. **Saturday 4 weeks before
    data:
    l_daynr like HRVSCHED-DAYNR.
    
    *Get today's date
    l_date = sy-datum.
    
    *Gey today's day (Monday, Tuesday, etc.)
    CALL FUNCTION 'HRIQ_GET_DATE_DAYNAME'
    EXPORTING 
    langu = 'EN'
    date = l_date
    IMPORTING
    daynr = l_daynr.
    
    CASE l_daynr.
    *If it is Monday
    WHEN 1.
    -Subtract 3 days for the first saturday
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 3
    IMPORTING
    ed_date = l_date2.
    
    -Subtract 31 days for the saturday 4 weeks before
    CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
    EXPORTING
    id_date = l_date
    id-operator = '-'
    is_duration = 32
    IMPORTING
    ed_date = l_date23.
    
    *If it is Tuesday
    WHEN 2.
    .... -> Like monday
    *If it is Wednesday
    WHEN 3.
    ....
    *If it is Thursday
    WHEN 4.
    *If it is Friday
    WHEN 5.
    *If it is Saturday
    WHEN 6.
    *If it is Sunday
    WHEN 7.
    
    ENDCASE.
    
    

    Regards,

    Dilek

    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.