09-03-2007 2:43 AM
Hello Gurus,
I am not an ABAPer, I work in BW module.
I have a requirement to write a routine which will check the following logic
In BW, I have a field called Posting Date (0PSTNG_DATE). This field is currently set to sy-datum. But i need to write a routine which will find last friday's date and update this field with friday's date.
Eg: If sy-datum = 03/09/2007 then i need to populate posting date field as 31/08/2007.
Sy-datum can be any day of the week. But it should always write last week friday's date.
Is there any standard function module which i can use here.
Thanks in advance.
Cheers
POPS
09-03-2007 4:06 AM
Function module DATE_COMPUTE_DAY will return you the day number for the date you specify... you can then write couple of extra lines of ABAP to work out how many days you need to take off "sy-datum" to get the last Friday (day = 5).
Jonathan
09-03-2007 4:06 AM
Function module DATE_COMPUTE_DAY will return you the day number for the date you specify... you can then write couple of extra lines of ABAP to work out how many days you need to take off "sy-datum" to get the last Friday (day = 5).
Jonathan
09-03-2007 4:12 AM
Hi POPS
Try to use this program . if you have any question , Please let me know.
PARAMETER p_date LIKE sy-datum.
DATA v_weekday LIKE dtresr-weekday.
DO.
CALL FUNCTION 'DATE_TO_DAY'
EXPORTING
date = p_date
IMPORTING
weekday = v_weekday.
IF v_weekday = 'Friday'.
WRITE : p_date .
EXIT.
ELSE.
p_date = p_date + 1.
ENDIF.
ENDDO.
Best Regards
Wiboon
09-03-2007 4:32 AM
Hi,
call function 'DAY_ATTRIBUTES_GET'
exporting
date_from = sy-datum
date_to = sy-datum
language = sy-langu
tables
day_attributes = i_day
exceptions
factory_calendar_not_found = 01
holiday_calendar_not_found = 02
date_has_invalid_format = 03
date_inconsistency = 04.
if i_day-weekday > 5.
v_friday = sy-datum - ( i_day-weekday - 5 ).
endif.
if i_day-weekday < 5.
v_friday = sy-datum - ( i_day-weekday + 2 ) .
endif.
if i_day-weekday = 5.
v_friday = sy-datum.
endif.
a®