Contact Form

Name

Email *

Message *

Cari Blog Ini

Calculate Working Days Between Two Dates Using Function Module

Calculate Working Days Between Two Dates Using Function Module

Understanding Factory Calendars

In SAP ABAP, a factory calendar assigns a unique serial integer, known as a factory date, to each day. This integer represents the day's position within the calendar.

Using HOLIDAY_GET Function Module

Finding Suitable Function Modules

To calculate working days between two dates, you can utilize the function module HOLIDAY_GET. This module determines whether a particular date is a holiday or a working day based on the factory calendar.

Calculating Working Days

Using this function module, you can pass two dates and the factory calendar as input parameters. The function will return the number of working days between those dates, excluding weekends and holidays.

Example Usage of HOLIDAY_GET

For example, the following statement calculates the working days between January 1, 2023, and January 10, 2023, using the factory calendar "FC01":

DATA: start_date TYPE date, end_date TYPE date, working_days TYPE i. start_date = '20230101'. end_date = '20230110'.  CALL FUNCTION 'HOLIDAY_GET'   EXPORTING     DATE_FROM = start_date     DATE_TO = end_date     CALENDAR_ID = 'FC01'   IMPORTING     WORK_DAY_CNT = working_days.  WRITE: 'Number of working days:', working_days.

Result

In this scenario, the output of the above code would be "5", as there are five working days between January 1, 2023, and January 10, 2023, excluding weekends.


Comments