cancel
Showing results for 
Search instead for 
Did you mean: 

How to derive week commencing date using print date in SAP BI Routine

Former Member
0 Kudos

Hi,

We've a requirement where we've to derive week commencing date (Sun- Sat) e.g. week commencing 03.08.2014 --- from below ZPRINT_DT into ZWKCOM field. Please can you give sample code how we can achieve this. Should it be written at field level or in end routine.

We want to achieve something similar as below:

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Pawan,

You can use below code.

-------------------------------------

   DATA: date_in TYPE sy-datum,
      date_out TYPE sy-datum.
     date_in = ZPRINT_DATE.          " here pass your print date
CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY'
  EXPORTING
    date_in        = date_in
IMPORTING
   DATE_OUT       = date_out
        .

-------------------------------------

Regards

Amit

Former Member
0 Kudos

Hi Pawan,

using below function module, you can derive the day of hte print date. then subtract that day from the print date, will you the Sunday's date (ie, week commencing date for you)

CALL FUNCTION 'DATE_COMPUTE_DAY'

     EXPORTING

       date = w_first_date    (pass your print date here)

     IMPORTING

       day  = w_day.  (this will give you day of the date)

eg. if you pass the date as 01.08.2014, it will return as day as 5. subtracting this 5 from 01.08.2014, will give you 27.07.2014 .

i hope this is what you are looking for ..

Regards,

Sakthi.