FORM SUB_CHECK_WORKING_DAY USING P_DATE
CHANGING P_prev_DATE.
DATA: L_INDATE LIKE SCAL-DATE,
L_OUTDATE LIKE SCAL-DATE,
L_DATE LIKE SCAL-DATE,
L_CHECK_HD TYPE C,
L_LANGU LIKE SY-LANGU VALUE 'E',
L_CALENDAR LIKE SCAL-FCALID VALUE 'HK',
T_DAY_ATTRIBUTES LIKE CASDAYATTR OCCURS 0,
W_DAY_ATTRIBUTES LIKE CASDAYATTR,
L_PERIOD LIKE ZISDMACCLC-ZZMONTHYEAR.
L_DATE P_DATE - 1. "pervious working date
CLEAR L_CHECK_HD.
** CHECK PEVIOUS WORKING DATE NOT PUBLIC HOLIDAY **
WHILE L_CHECK_HD IS INITIAL.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
FACTORY_CALENDAR L_CALENDAR
HOLIDAY_CALENDAR L_CALENDAR
DATE_FROM L_DATE
DATE_TO L_DATE
LANGUAGE L_LANGU
* IMPORTING
* YEAR_OF_VALID_FROM
* YEAR_OF_VALID_TO
* RETURNCODE
TABLES
DAY_ATTRIBUTES
T_DAY_ATTRIBUTES
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 T_DAY_ATTRIBUTES INTO W_DAY_ATTRIBUTES
INDEX 1.
IF W_DAY_ATTRIBUTES-HOLIDAY IS INITIAL.
L_CHECK_HD 'X'.
P_PREV_DATE L_DATE.
ELSE.
L_INDATE L_DATE.
ENDIF.
** IF HOLIDAY, CONTINUE CHECKING **
CHECK L_CHECK_HD IS INITIAL.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
CORRECT_OPTION '-'
DATE L_INDATE
FACTORY_CALENDAR_ID 'HK'
IMPORTING
DATE L_OUTDATE
* FACTORYDATE
* WORKINGDAY_INDICATOR
EXCEPTIONS
CALENDAR_BUFFER_NOT_LOADABLE 1
CORRECT_OPTION_INVALID 2
DATE_AFTER_RANGE 3
DATE_BEFORE_RANGE 4
DATE_INVALID 5
FACTORY_CALENDAR_NOT_FOUND 6
OTHERS 7
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
L_DATE L_OUTDATE.
ENDWHILE.
ENDFORM. " sub_check_working_day
No comments:
Post a Comment