Here is some sample code that allows you to determine if a date passed as parameter is a holiday or a weekend day.
FORM check_if_holiday USING value(fact_cal) LIKE scal-fcalid value(holiday_cal) LIKE scal-hcalid a_date TYPE d. FIELD-SYMBOLS :TYPE casdayattr. DATA days_attr_tbl TYPE STANDARD TABLE OF casdayattr. * get the attributes for the specified day CALL FUNCTION 'DAY_ATTRIBUTES_GET' EXPORTING factory_calendar = fact_cal " default 'GR' holiday_calendar = holiday_cal " default 'GR' date_from = a_date date_to = a_date language = sy-langu * IMPORTING * YEAR_OF_VALID_FROM = * YEAR_OF_VALID_TO = * RETURNCODE = TABLES day_attributes = days_attr_tbl EXCEPTIONS factory_calendar_not_found = 1 holiday_calendar_not_found = 2 date_has_invalid_format = 3 date_inconsistency = 4 OTHERS = 5. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. READ TABLE days_attr_tbl INDEX 1 ASSIGNING <day_attr>. IF NOT <day_attr>-holiday_id IS INITIAL. MESSAGE w888(sabapdocu) WITH a_date text-e05 <day_attr>-txt_long. ENDIF. IF <day_attr>-weekday = '6' OR <day_attr>-weekday = '7'. MESSAGE w888(sabapdocu) WITH a_date text-e06 -weekday_l. ENDIF. ENDFORM. " check_if_holiday
The parameters fact_cal and holiday_cal are two letter country code representations, so in my case, they may be hard coded to the value 'GR'.
A practical way to use the above would be :
On the screen flow logic
PROCESS AFTER INPUT. ... FIELD input_date MODULE input_date_changed ON REQUEST.
On the actual code
MODULE input_date_changed INPUT. PERFORM check_if_holiday USING 'GR' 'GR' input_date. ENDMODULE.
No comments :
Post a Comment