Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

valid date

Former Member
0 Kudos

hi all,

is there any function module to check valid date ??

ex:

30021992 - is valid date.

12102007 - is valid date.

12342007- is invalid date.

aa122009- is invalid date.

thanks and regards.

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please check this FM

DATE_CHECK_PLAUSIBILITY

CONVERSION_EXIT_SDATE_INPUT

Regards,

Ferry Lianto

3 REPLIES 3

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please check this FM

DATE_CHECK_PLAUSIBILITY

CONVERSION_EXIT_SDATE_INPUT

Regards,

Ferry Lianto

Former Member
0 Kudos

hi Abdul,

Use function module <b>'DATE_CHECK_PLAUSIBILITY'</b>.

sample code.


DATA: _DATE LIKE SY-DATUM,
      _MESSAGE(100) TYPE C.
 
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
     EXPORTING
          DATE                      = _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 INTO _MESSAGE.
ENDIF.

Hope this helps,

Sajan Joseph.

former_member181962
Active Contributor
0 Kudos

Hi Abdul,

The FMs that are mentioned will work if the input is of YYYYMMDD format.

YOu need to convert your date into that format and then use the FM.

data: date(8) value '30021992',
newdate type sy-datum.

concatenate date+4(4) date+292) date+0(2) into newdate.

CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
  EXPORTING
    DATE                            = NEWDATE
 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.