检查日期和时间的合法性
REPORT ZWYB_072. DATA LV_TIME TYPE SY-UZEIT. DATA LV_TIME_1 TYPE SY-UZEIT. LV_TIME = SY-UZEIT. LV_TIME_1 = '12:23:' . DATA LV_DATUM TYPE SY-DATUM. DATA LV_DATUM_2 TYPE SY-DATUM. LV_DATUM = SY-DATUM. LV_DATUM_2 = '2019-11-' . CALL FUNCTION 'TIME_CHECK_PLAUSIBILITY' EXPORTING TIME = LV_TIME EXCEPTIONS PLAUSIBILITY_CHECK_FAILED = 1 OTHERS = 2. IF SY-SUBRC NE 0. "如果返回非0,则时间不合法 WRITE /: LV_TIME && '不合法' . ELSE. WRITE /:LV_TIME && '合法' . ENDIF. CALL FUNCTION 'TIME_CHECK_PLAUSIBILITY' EXPORTING TIME = LV_TIME_1 EXCEPTIONS PLAUSIBILITY_CHECK_FAILED = 1 OTHERS = 2. IF SY-SUBRC NE 0. "如果返回非0,则时间不合法 WRITE /: LV_TIME_1 && '不合法' . ELSE. WRITE /:LV_TIME_1 && '合法' . ENDIF. CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY' EXPORTING DATE = LV_DATUM EXCEPTIONS PLAUSIBILITY_CHECK_FAILED = 1 OTHERS = 2. IF SY-SUBRC NE 0. "如果返回非0,则时间不合法 WRITE /: LV_DATUM && '不合法' . ELSE. WRITE /:LV_DATUM && '合法' . ENDIF. CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY' EXPORTING DATE = LV_DATUM_2 EXCEPTIONS PLAUSIBILITY_CHECK_FAILED = 1 OTHERS = 2. IF SY-SUBRC NE 0. "如果返回非0,则时间不合法 WRITE /: LV_DATUM_2 && '不合法' . ELSE. WRITE /:LV_DATUM_2 && '合法' . ENDIF.