2007 Feb 22 7:13 PM
Hi all ,
I need an FM or any logic with the following functionality :
Take the current system date and find what is the date on the last Monday ?
Can anyone guide me how to do this ?
Regards ,
Vijay .
Hi all ,
I need an FM or any logic with the following functionality :
Take the current system date and find what is the date on the last Monday ?
Can anyone guide me how to do this ?
Regards ,
Vijay .
2007 Feb 22 7:16 PM
Hi,
At present I am not in front of PC.. But there is a function module for factory calender where u can do this work.
Plz go to se37 and find function module by putting string Factory IN Description.
Darshan
2007 Feb 22 7:18 PM
Hi all ,
Hopefully I found the solution . You can always correct me if I am wrong .
Using the FM <b> HR_GB_DAY_RELATIVE_TO_DATE</b> if you give the current date it will give you the last Sunday date . Adding 1 to that will give you Monday's date .
This is the solution I have found . If any one see any issues please reply to this .
Thanks ,
Vijay .
2007 Feb 22 7:18 PM
2007 Feb 22 7:21 PM
There r plenty of FMs available in SAP but u hav to check it out for which country u need the FM. go to SE15 for any SAP repository. and put FM description there...
try to check out wat is the calender id
hope this will help
Ashwani
2007 Feb 22 7:25 PM
Try this:
REPORT ztest MESSAGE-ID 00.
DATA: start_date TYPE sy-datum,
day_name TYPE hrvsched-daytxt.
start_date = sy-datum.
DO.
CALL FUNCTION 'RH_GET_DATE_DAYNAME'
EXPORTING
langu = sy-langu
date = start_date
IMPORTING
daytxt = day_name
EXCEPTIONS
no_langu = 1
no_date = 2
no_daytxt_for_langu = 3
invalid_date = 4
OTHERS = 5.
IF day_name = 'Monday'.
EXIT.
ELSE.
start_date = start_date - 1.
ENDIF.
ENDDO.
WRITE: 'Monday is', start_date.
Rob
2007 Feb 22 7:25 PM
Hi Vijay,
Please try this.
DATA: DAY TYPE P,
WA_DATE LIKE SY-DATUM.
CALL FUNCTION 'DAY_IN_WEEK'
EXPORTING
datum = sy-datum
IMPORTING
wotnr = day.
CASE DAY.
WHEN '1'.
WA_DATE = SY-DATUM.
WHEN '2'.
WA_DATE = SY-DATUM - 1.
WHEN '3'.
WA_DATE = SY-DATUM - 2.
WHEN '4'.
WA_DATE = SY-DATUM - 3.
WHEN '5'.
WA_DATE = SY-DATUM - 4.
WHEN '6'.
WA_DATE = SY-DATUM - 5.
WHEN '7'.
WA_DATE = SY-DATUM - 6.
ENDCASE.
WRITE: / 'Last Monday date from today date is ', WA_DATE.
Regards,
Ferry Lianto
2007 Feb 22 9:13 PM
The solution I suggested in my 2nd reply works well and I have tested it well to confirm the results .
Thanks to all for your inputs .
Even Rob's and Ferry's soution are also working .
2007 Feb 22 9:18 PM
Maybe I'm confused about your problem, but does your solution still work if you enter a date that is a Sunday into that FM?
Message was edited by:
Matt Nagel
Message was edited by:
Matt Nagel
2007 Feb 22 9:33 PM
What do you want to do if today is Monday? Take today or go back a week?
Rob
2007 Feb 22 9:40 PM
Hi ,
The FM I have suggested works for my situation since we are not going to run the report on Sunday .This report is scheduled to run any time on Wed, Thu, Fri once in a week .
Just in case we enter Sunday it returns the same date , in that case we are planning to abort the run of the report .
Any suggestions ??
Thanks ,
Vijay .
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |