Joined: 03 Jun 2005 Posts: 4 Location: Belfast, United Kingdom
Hi All,
Could you please help me...
I need to validate the I/P file which is having date from 44th position to 54th position in CCYY-MM-DD format. I had written the sortcard for this as below.
-------------------------------------------------------------------------------------
Please let me know is there any method to do this other than above.
Is there anything like DATE function to do this ??
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
sridharxs wrote:
Hi All,
Could you please help me...
I need to validate the I/P file which is having date from 44th position to 54th position in CCYY-MM-DD format. I had written the sortcard for this as below.
Some problems
for the CC field at 44,2 anything that starts with a 1 thru 8 would be considered as valid, 1E, 2A, 3 , 4G etc and most anything that starts with a 9 would be considered as valid.
for the YY field at 46,2 has basically the same problem
for the MM field at 49,2 most anything that starts with a 1 would be considered as valid, 1A, 1B, 1C etc
for the DD field at 52,2 anything that starts with a 1 or a 2 would be considered valid and 3A thru 3Z and others would be considered as valid, also 29, 30, 31 are valid only for certain months.
To be even close to correct you would first have to check that 44,2 46,2 49,2 and 52,2 are numeric. You would still have the possibility of invalid days for some months.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
sridharxs,
There is a way to validate the DATE with a bunch of IFTHEN's. If you are interested I can show it , however I need the LRECL and RECFM of the input dataset. Also what exactly you want to do with the invalid date records? Copy them into a different file?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
The following DFSORT does the validation of dates. It even checks for leap years. The valid date ranges are from 1000-01-01 to 8999-12-31. We split the file into 2 output files VALDATE which contains all records with a valid date and the invalid date records go to INVALID dd.