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

need a function module

Former Member
0 Likes
452

friends,

good.. is there any function module that can give the total no. of sundays that lies between two dates? i want to calculate the total no. of working days between two dates and if there are any sundays, i will have to decrement the value by 1...thanks all

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
422

refer this program and FM

you can get name of the week day

loop with your date and cound no of sundys with that

DATA: BEGIN OF DAYNAMES OCCURS 0.

INCLUDE STRUCTURE T246.

DATA: END OF DAYNAMES.

DATA: V_WEEK LIKE SCAL-WEEK,

WOTNR TYPE P,

V_MONDAY LIKE SCAL-DATE.

  • GET THE CURRENT WEEK OF A DATE

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

DATE = SY-DATUM

IMPORTING

WEEK = V_WEEK "YYYYWW

EXCEPTIONS

DATE_INVALID = 1

OTHERS = 2.

  • GET THE DATE OF THE FIRST MONDAY OF THE WEEK

CALL FUNCTION 'WEEK_GET_FIRST_DAY'

EXPORTING

WEEK = V_WEEK

IMPORTING

DATE = V_MONDAY

EXCEPTIONS

WEEK_INVALID = 1

OTHERS = 2.

  • DAY NUMBER OF A DATE

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = SY-DATUM

IMPORTING

WOTNR = WOTNR.

  • NAMES OF THE DAYS

CALL FUNCTION 'WEEKDAY_GET'

EXPORTING

LANGUAGE = SY-LANGU

TABLES

WEEKDAY = DAYNAMES.

READ TABLE DAYNAMES WITH KEY WOTNR = WOTNR.

WRITE:/ 'DATE:', SY-DATUM,

/ 'WEEK NUMBER:', V_WEEK+4,

/ 'FIRST DAY OF WEEK:', V_MONDAY,

/ 'CURRENT DAY OF WEEK:', DAYNAMES-LANGT.

Rewads if helpful.

3 REPLIES 3
Read only

Former Member
0 Likes
422

Hi

try using this FM

HOLIDAY_GET

Regards

Shiva

Read only

Former Member
0 Likes
423

refer this program and FM

you can get name of the week day

loop with your date and cound no of sundys with that

DATA: BEGIN OF DAYNAMES OCCURS 0.

INCLUDE STRUCTURE T246.

DATA: END OF DAYNAMES.

DATA: V_WEEK LIKE SCAL-WEEK,

WOTNR TYPE P,

V_MONDAY LIKE SCAL-DATE.

  • GET THE CURRENT WEEK OF A DATE

CALL FUNCTION 'DATE_GET_WEEK'

EXPORTING

DATE = SY-DATUM

IMPORTING

WEEK = V_WEEK "YYYYWW

EXCEPTIONS

DATE_INVALID = 1

OTHERS = 2.

  • GET THE DATE OF THE FIRST MONDAY OF THE WEEK

CALL FUNCTION 'WEEK_GET_FIRST_DAY'

EXPORTING

WEEK = V_WEEK

IMPORTING

DATE = V_MONDAY

EXCEPTIONS

WEEK_INVALID = 1

OTHERS = 2.

  • DAY NUMBER OF A DATE

CALL FUNCTION 'DAY_IN_WEEK'

EXPORTING

DATUM = SY-DATUM

IMPORTING

WOTNR = WOTNR.

  • NAMES OF THE DAYS

CALL FUNCTION 'WEEKDAY_GET'

EXPORTING

LANGUAGE = SY-LANGU

TABLES

WEEKDAY = DAYNAMES.

READ TABLE DAYNAMES WITH KEY WOTNR = WOTNR.

WRITE:/ 'DATE:', SY-DATUM,

/ 'WEEK NUMBER:', V_WEEK+4,

/ 'FIRST DAY OF WEEK:', V_MONDAY,

/ 'CURRENT DAY OF WEEK:', DAYNAMES-LANGT.

Rewads if helpful.

Read only

Former Member
0 Likes
422

Hi Satish,

You can use DATE_COMPUTE_DAY to determine if a given date is a Sunday or not. The rest of the algorithm to compute the number of non-Sundays between two dates is easy