*&---------------------------------------------------------------------*
*& REPORT ZJOI_TEST
*&
*&---------------------------------------------------------------------*
*& 获取某期间工作日天数
*&---------------------------------------------------------------------*
REPORT ZJOI_TEST.
PARAMETERS: P_FROM TYPE SY-DATUM,
P_TO TYPE SY-DATUM.
DATA: IT_TAB TYPE STANDARD TABLE OF CASDAYATTR.
DATA: L_DAYS TYPE I.
START-OF-SELECTION.
* 日期段内工作日数
PERFORM F_GET_DAYS USING P_FROM
P_FROM
CHANGING L_DAYS.
END-OF-SELECTION.
* 输出始末日期和这期间工作日数
WRITE: / 'FROM:',P_FROM.
WRITE: / 'TO:' ,P_TO.
WRITE: / '期间工作日数:' , L_DAYS.
*&---------------------------------------------------------------------*
*& FORM F_GET_DAYS
*&---------------------------------------------------------------------*
* 计算两个日期间所有工作日的天数
*----------------------------------------------------------------------*
* -->I_FROM TEXT
* -->I_FROM TEXT
* <--O_DAYS TEXT
*----------------------------------------------------------------------*
FORM F_GET_DAYS USING I_FROM TYPE SY-DATUM
I_TO TYPE SY-DATUM
CHANGING O_DAYS TYPE I.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
* FACTORY_CALENDAR = ' '
* HOLIDAY_CALENDAR = ' '
DATE_FROM = P_FROM
DATE_TO = P_TO
LANGUAGE = SY-LANGU
* NON_ISO = ' '
* IMPORTING
* YEAR_OF_VALID_FROM =
* YEAR_OF_VALID_TO =
* RETURNCODE =
TABLES
DAY_ATTRIBUTES = IT_TAB
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.
DELETE IT_TAB WHERE WEEKDAY = 6 OR WEEKDAY = 7.
DESCRIBE TABLE IT_TAB LINES O_DAYS.
ENDFORM. " F_GET_DAYS
阅读(2156) | 评论(0) | 转发(0) |