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

Validate Date?

Former Member
0 Likes
540

Hi guys,

I have to transfer a file in a transaction. The file contains Dates but one of the date is wrong. The date is like this 45.03.2007. How should we validate this date? I do not want to transfer this record from flat file to the transaction.

Thanks

3 REPLIES 3
Read only

Former Member
0 Likes
518

I'm assuming that your date field is formatted the way you want but the data is incorrect.

There are a number of things you could do. The easiest is to perform a subtring check on the field - check to make sure the DAY digits are between 1 and 31, the MONTH digits between 1 and 12 etc.. This won't always work b/c months have differing # of days.

The next thing you could do is find a FM that calculates something based on an input date - for example, find one that gets the Day of the Week based on date. If the FM fails, you most likely have a bad input date.

I'm sure there are many FMs available - go to SE37 and search for checkdate* or getdate* or something like that.

Lastly, you can always debug a date field validation in SAP to see how they do it.

Read only

Former Member
0 Likes
518

You can use FM DATE_CHECK_PLAUSIBILITY

Read only

naimesh_patel
Active Contributor
0 Likes
518

Try this FM:

CONVERT_DATE_TO_INTERNAL

Enter your date, how it is coming in the flat file.

If the date is invalid, FM gives the exception, DATE_EXTERNAL_IS_INVALID.

Regards,

Naimesh Patel