Application Development and Automation 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: 
Read only

Verify date format in module pool

Former Member
0 Likes
459

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.

2 REPLIES 2
Read only

Former Member
0 Likes
387

HI

Take the Help of Class

CL_ABAP_DATFM and Table T005X

Pass 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

Read only

Former Member
0 Likes
387

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.