cancel
Showing results for 
Search instead for 
Did you mean: 

Derived week commencing from date

Former Member
0 Kudos

Hi

We're deriving week commencing from date, but I'm not getting correct results as expected.

Please see code below and recommend what change should need to make to get correct result.  I've attached below codes and how results should look like and what it is coming now

code: (field level routine)

this is how it should look like:

it

this is what it is coming now,, could please correct me what should change to get above:

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Pawan,

Try this field routine code.

DATA: L_WEEK TYPE KWEEK,
      L_DATE
TYPE SY-DATUM,
      F_DATE
TYPE SY-DATUM,
      DAY_NO
TYPE SCAL-INDICATOR.
      L_DATE = SOURCE_FIELDS-PRINTDATE.

CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = L_DATE
IMPORTING
DAY = DAY_NO.
IF DAY_NO EQ 7.         
RESULT = L_DATE.
ELSE.
CALL FUNCTION 'BWSO_DATE_GET_FIRST_WEEKDAY' 

  *****Get 1st day of week (Monday Date)
EXPORTING
DATE_IN = L_DATE
IMPORTING
DATE_OUT = F_DATE.

   F_DATE = F_DATE - 1.
   RESULT = F_DATE.
ENDIF.


Thanks,

Somesh.

Former Member
0 Kudos

Thanks Somesh. It's worked

Former Member
0 Kudos

Hi Sumesh,

How can I calculate Cal week based on finished date? As used wants both cal week and fiscal week in the report.

What changes need to make for calculating cal week based on finish date.

Former Member
0 Kudos

Hi Pawan,

you need to add one more condition, if the date is sunday, then populate the same date as print date.

for eg:-

pass the date to the below FM, and if the day is 7 i.e Sunday,

then zWkcom = Zprint_dt

CALL FUNCTION 'DATE_COMPUTE_DAY'

     EXPORTING

       date = w_first_date    (pass your print date here)

     IMPORTING

       day  = w_day.

Regards,

Sakthi.

Former Member
0 Kudos

Hi ,

do you meanmean to above logic won't work??

if yes, where I can apply this logic in my code.

PLease can you sample code.

Former Member
0 Kudos

ALso, how to do declaration part here.

Former Member
0 Kudos

HI

can someone help this??

KodandaPani_KV
Active Contributor
0 Kudos

Hi pawan,

please explain the requirement about ZWEKCOM and ZPRINT_DT

you want week derived form the ZWEKCOM ?

you want like this

01.01.2014 - Ist week

07.01.2014 - 2nd week

14.01.2014 - 3rd week

Thanks,

Phani.

Former Member
0 Kudos

HI

we're deriving week commencing from print date.

Week Commencing is from Sunday - Saturday.

E.g. When print date is from 10.08-16.08.2014 then week commencing is 10.08.2014

when print date is from 17.08.2014-- 23.08.2014 then week commencing is 17.08.2014

( in above code when print date is 17.08.2014 it's still picking 10.08.2014

can you provide sample code please??