Some FM/BAPIs will not check whether date is valid or not and it will update whatever values you pass to it.
Then how can we check whether date is valid? Just use the function module
DATE_CHECK_PLAUSIBILITY to check the date is valid or not.
*&---------------------------------------------------------------------* *& Data Declaration *&---------------------------------------------------------------------* DATA: g_date TYPE sy-datum. *&---------------------------------------------------------------------* *& Start Of Selection *&---------------------------------------------------------------------* START-OF-SELECTION. g_date = '99999999'. *Check whether Date is valid CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY' EXPORTING date = g_date EXCEPTIONS plausibility_check_failed = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
Output
*&---------------------------------------------------------------------* *& Data Declaration *&---------------------------------------------------------------------* DATA: g_date TYPE sy-datum. *&---------------------------------------------------------------------* *& Start Of Selection *&---------------------------------------------------------------------* START-OF-SELECTION. g_date = 'abcd'. *Check whether Date is valid CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY' EXPORTING date = g_date EXCEPTIONS plausibility_check_failed = 1 OTHERS = 2. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
Output