Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP Function module for BW

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

Former Member
0 Kudos

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

former_member194669
Active Contributor
0 Kudos

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.