Get an overview of the ABAP classes, interfaces, and methods you can use to access calendar-related information.
The calendar system comprises the definition of the following categories:
-
Public holidays
-
Holiday calendars (a collection of public holidays)
-
Factory calendars
A factory calendar is based on a country-specific holiday calendar and defines which days are working days, for example, Monday to Friday, and location-specific rules.
Read on to learn about the set of data we deliver for these categories.
Class
CL_SCAL_API
is still available, but deprecated. We recommend that you use classCL_FHC_CALENDAR_RUNTIME
and the related interfacesIF_FHC_FCAL_RUNTIME
,IF_FHC_HCAL_RUNTIME
andIF_FHC_HOLIDAY_RUNTIME
instead. Furthermore, the CDS views from the section Accessing Holiday and Factory Calendar Tables Using VDM-Compliant CDS Views can be used to get an overview of existing factory- and holiday calendars. For information about the mapping between SCAL-relevant IDs and FHC-relevant IDs, see the corresponding section below.
Use class CL_FHC_CALENDAR_RUNTIME
that contains the following list of methods to create a runtime for holidays, holiday calendars, and factory calendar:
Method |
Description |
---|---|
create_factorycalendar_runtime |
Provides a factory calendar runtime |
create_holidaycalendar_runtime |
Provides a holiday calendar runtime |
create_holiday_runtime |
Provides a holiday runtime |
try. data(lo_fcal_run) = cl_fhc_calendar_runtime=>create_factorycalendar_runtime ( iv_factorycalendar_id = 'ExampleID' ). catch cx_fhc_runtime into data(lx_err). "exception handling endtry.
Use the before created runtime to access the following list of methods provided in the interface IF_FHC_FCAL_RUNTIME
to get information about the factory calendar:
Method |
Description |
---|---|
convert_date_to_factorydate |
Converts a date to a factory date |
convert_factorydate_to_date |
Converts a factory date to a date |
get_last_factorydate |
Provides the last factory date of the calendar |
calc_workingdays_between_dates |
Calculates the number of working days between two dates |
add_workingdays_to_date |
Adds working days to a date |
subtract_workingdays_from_date |
Subtracts working days to a date |
get_validity_start |
Provides the first valid date |
get_validity_end |
Provides the last valid date |
is_date_workingday |
Check if a weekday is a working day |
is_holiday_workingday |
Check if holiday is a working day |
get_description |
Provides the description of the calendar |
get_hcal_assignment |
Provides the assigned holiday calendar runtime |
get_id |
Provides the ID of the factory calendar |
try. data(lv_date) = lo_fcal_run->convert_factorydate_to_date( iv_factorydate = '123' ). catch cx_fhc_runtime into data(lx_run_err). "exception handling endtry.
Use the before created runtime to access the following list of methods provided in the interface IF_FHC_HCAL_RUNTIME
to get information about the holiday calendar:
Method |
Description |
---|---|
is_holiday |
Check if a date is a holiday |
get_holiday |
Provides the assigned holiday for a date |
calc_holidays_between_dates |
Calculates the number of holidays between two dates |
get_validity_start |
Provides the first valid date |
get_validity_end |
Provides the last valid date |
get_description |
Provides the description of the calendar |
get_holiday_assignments |
Get the assigned holidays from current holiday calendar |
get_id |
Provides the ID of the holiday calendar |
Use the before created runtime to access the following list of methods provided in the interface IF_FHC_HOLIDAY_RUNTIME
to get information about the holidays:
Method |
Description |
---|---|
get_holiday_id |
Provides the ID of the holiday |
get_type |
Provides the type of the holiday |
get_class |
Provides the class of the holiday |
get_confession |
Provides the confession of the holiday |
get_text |
Provides the title and description of the holiday in a specific language |
Class CL_FHC_CALENDAR_RUNTIME
uses longer IDs (32 digits) than the deprecated class CL_SCAL_API
, which had only two-digit IDs for the factory calendars and holiday calendars, and three-digit IDs for the public holidays (also referred to as legacy IDs). The longer IDs make it easier to categorize calendar data.
To enable the use of the above mentioned runtimes, it may be necessary that an application establishes a connection between a legacy two-digit ID (as formerly used with CL_SCAL_API
) and a longer ID that the newer class CL_FHC_CALENDAR_RUNTIME
uses.
You can do such a mapping using the interface IF_FHC_ID_MAPPER and class CL_FHC_CALENDAR_ID_MAPPER
. The mapping is available for holidays, holiday calendars, and factory calendars.
The CL_FHC_CALENDAR_ID_MAPPER
class returns an ID mapper instance. Subsequently, you can use the methods provided by the interface IF_FHC_ID_MAPPER
to perform the desired mappings.
It can't be guaranteed that the 2-digit legacy ID will point to the same calendar on each system. The 2-digit legacy ID should only be used if applications have already used
CL_SCAL_API
, stored the 2-digit legacy ID and have not yet migrated to the new APIs and IDs. The 2-digit legacy IDs are only intended for the transition phase.We recommend using and saving the new 32-digit IDs on the application side. The whole functionality is optimized for using the new 32-digit ID.
Method |
Description |
---|---|
create_id_mapper |
Provides an ID mapper instance |
data(lo_id_mapper) = cl_fhc_calendar_id_mapper=>create_id_mapper( ).
Method |
Description |
---|---|
mapping_fcal_legacyid_to_id |
Provides the 32-digit factory calendar ID for a two-digit SCAL factory calendar ID |
mapping_hcal_legacyid_to_id |
Provides the 32-digit holiday calendar ID for a two-digit SCAL holiday calendar ID |
mapping_hol_legacyid_to_id |
Provides the 32-digit holiday ID for a three-digit SCAL holiday ID |
mapping_fcal_id_to_legacyid |
Provides the two-digit SCAL factory calendar ID for a 32-digit factory calendar ID |
mapping_hcal_id_to_legacyid |
Provides the two-digit SCAL holiday calendar ID for a 32-digit holiday calendar ID |
mapping_hol_id_to_legacyid |
Provides the three-digit SCAL holiday calendar ID for a 32-digit holiday ID |
try. data(lv_new_id) = lo_id_mapper->mapping_fcal_legacyid_to_id( iv_legacy_id = '01' ). catch cx_fhc_runtime into data(lx_err). "exception handling endtry. "another example try. data(lv_legacy_id) = lo_id_mapper->mapping_fcal_id_to_legacyid( iv_factorycalendar_id = 'ExampleID' ). catch cx_fhc_runtime into lx_err. "exception handling endtry.
Independently from the above factory calendar information, you can use class CL_SCAL_UTILS
, which contains the following methods:
Method |
Description |
---|---|
MONTH_NAMES_GET |
Provides the names of the months |
WEEK_GET_FIRST_DAY |
Provides the first day of a week |
DATE_GET_WEEK |
Provides the year and week of a date |
DATE_COMPUTE_DAY |
Provides the name and number of the weekday for a specified date |
try. cl_scal_utils=>date_get_week( exporting iv_date = '20201001' importing ev_year = data(lv_year) ev_week = data(lv_week) ). catch cx_scal into data(lx_scal). "exception handling endtry.