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

Function module to return Wednesday

Former Member
0 Likes
904

Hi,

Is there any standard function module that returns the date of the week which is a Wednesday.

For e.g The function module BWSO_DATE_GET_FIRST_WEEKDAY returns that first day of week Monday 22/10/2012 if we enter today's date as input.

Similarly is there any function module that returns Wednesday.

Thanks.

4 REPLIES 4
Read only

laurent_fournier2
Contributor
0 Likes
782

Hi,

Maybe dummy but why don't you use BWSO_DATE_GET_FIRST_WEEKDAY and add 2 to get Wednesday ?

I don't think that a FM exists that returns the date for a specific day of the week.

Regards.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
782

Look for FM whose names match *WEEK*DAY*, depending on your version, you could find some FMs like /OSP/GETDATE_WEEKDAY.

Regards,

Raymond

Read only

amy_king
Active Contributor
0 Likes
782

Hi Prasy,

Try function module GET_WEEK_INFO_BASED_ON_DATE. This function module takes a date as input and returns the week number as well as the dates for Monday and Sunday of that week. You can then simply take the returned value for Monday and add 2 to the date, e.g.,

wednesday = monday + 2.

The ECC system can do math with date values, so this will give you the date for Wednesday.

Cheers,

Amy

Read only

alex_campbell
Contributor
0 Likes
782

Function Group SCAL has a couple of useful functions which are documented and released for customer use by SAP (using these is much safer than using undocumented, not released FMs). Specifically you can use FM WEEK_GET_FIRST_DAY to get the first day of the week and in a WHILE loop, call FM DATE_COMPUTE_DAY while incrementing the date until Wednesday is returned.

Note that which day of the week is used as the first day (Sat, Sun, or Mon) is controlled through Config and User Exits so you shouldn't assume that the first day of the week is a certain day. This is why I recommend calling DATE_COMPUTE_DAY inside a loop instead of simply adding a constant number or days).