Application Development and Automation 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: 
Read only

Custom Week - ABAP

f_allocca
Participant
0 Kudos
1,899

Hi Experts,

Previously I asked for a way to derive Year and Week number respecting the following specifications:

  1. The first week of the year is the one that starts on Sunday
  2. The first day of the week is Sunday

Here is an example screen:

I was advised to use the following method and it works: (Number of week in 'v_week' variable)

Now I need a way to calculate the data (YYYYMMDD) starting from Year and Week (YYYYWW) respecting the same specifications above

Thanks

Francesco

1 ACCEPTED SOLUTION
Read only

swapan_sarkar1
Participant
0 Kudos
1,826

You may just want to create a custom table with Year, Week & date of first & last date of the week for next 100 years (you may write a script for that). There will be about 5200 - 5300 records in it. This will help with performance if you are using CDS views and want to use it in a JOIN.

5 REPLIES 5
Read only

Sandra_Rossi
Active Contributor
0 Kudos
1,826

If you know which day of the week is January 1st, as a number between 1 and 7 (not sure in your case which number is Sunday), then you can determine how many days are to be added to reach Sunday. Can't you? Is there any problem.

Read only

f_allocca
Participant
0 Kudos
1,826

from 2021.02 (YYYY.WW) Wednesday I need to calculate what date corresponds, for example 13.01.2021 (DD.MM.YYYY)

How can I do it?

Read only

FredericGirod
Active Contributor
1,826

number of week * 7

I win the price ??

Read only

swapan_sarkar1
Participant
0 Kudos
1,827

You may just want to create a custom table with Year, Week & date of first & last date of the week for next 100 years (you may write a script for that). There will be about 5200 - 5300 records in it. This will help with performance if you are using CDS views and want to use it in a JOIN.

Read only

Sandra_Rossi
Active Contributor
0 Kudos
1,826

So you know that first week in the year (2021.01) starts on 06.01.2021.

Week 2021.02 starts on 13.01.2021.

Week 2021.03 starts on 20.01.2021.

I think that frdric.girod won the price!