‎2009 Nov 23 5:14 AM
Hi all,
I am working in module pool. My requirement needs to verify the date format in dd.mm.yyyy.
If the entered date format is yyyy.mm.dd, then prompt error message.
Can this be done?
Please advise.
‎2009 Nov 23 6:11 AM
HI
Take the Help of Class
CL_ABAP_DATFM and Table T005XPass your Country Key to Table T005X and pass this get Methods in the Class CL_ABAP_DATFM
This will take you to correct Solution but some work around is needed.
For Further Help Go Put Debug for TCode SU01
Hope this is clear to you.
Cheerz
Ram
‎2009 Nov 23 6:23 AM
There are two ways in solving this problem.
1) If u can use 'DATS' as data type for the parameter ypu are entering date then the system generates error on its own.
2)If u cant use dats then you can use the code below for validating the date format.
suppose u have a start date as parameter p_sdat.
IF ( p_sdat+4(4) LE c_0000
OR p_sdat+0(4) GT c_9999
)
OR ( p_sdat+2(2) LT c_1
OR p_sdat+2(2) GT c_12
)
OR ( p_sdat+0(2) LT c_1
OR p_sdat+0(2) GT c_31
) .
MESSAGE 'Invalid date'.
ENDIF.