|
|
| Author |
Message |
sridharxs
New User
Joined: 03 Jun 2005 Posts: 4 Location: India
|
|
|
|
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.
| Code: |
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(INDD1) USING(ALL2)
//ALL2CNTL DD *
OUTFIL FNAMES=OUTDD1,INCLUDE=(44,2,CH,GE,C'01',AND,
44,2,CH,LE,C'99',AND,
46,2,CH,GE,C'00',AND,
46,2,CH,LE,C'99',AND,
48,1,CH,EQ,C'-',AND,
49,2,CH,GE,C'01',AND,
49,2,CH,LE,C'12',AND,
51,1,CH,EQ,C'-',AND,
52,2,CH,GE,C'01',AND,
52,2,CH,LE,C'31')
OUTFIL FNAMES=OUTDD2,OMIT=(44,2,CH,GE,C'01',AND,
44,2,CH,LE,C'99',AND,
46,2,CH,GE,C'00',AND,
46,2,CH,LE,C'99',AND,
48,1,CH,EQ,C'-',AND,
49,2,CH,GE,C'01',AND,
49,2,CH,LE,C'12',AND,
51,1,CH,EQ,C'-',AND,
52,2,CH,GE,C'01',AND,
52,2,CH,LE,C'31')
/*
//INDD1 DD DSN=XX.EXTRACT.G4243,DISP=SHR
//OUTDD1 DD DSN=YY.EXTRACT.OUT,DISP=OLD
//OUTDD2 DD DSN=ZZ.EXTRACT.OMIT,DISP=OLD
//
|
-------------------------------------------------------------------------------------
Please let me know is there any method to do this other than above.
Is there anything like DATE function to do this ??
Regards,
Sridhar |
|
| Back to top |
|
 |
References
|
|
 |
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1027 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. |
| Code: |
OUTFIL FNAMES=OUTDD1,INCLUDE=(44,2,CH,GE,C'01',AND,
44,2,CH,LE,C'99',AND,
46,2,CH,GE,C'00',AND,
46,2,CH,LE,C'99',AND,
48,1,CH,EQ,C'-',AND,
49,2,CH,GE,C'01',AND,
49,2,CH,LE,C'12',AND,
51,1,CH,EQ,C'-',AND,
52,2,CH,GE,C'01',AND,
52,2,CH,LE,C'31')
OUTFIL FNAMES=OUTDD2,OMIT=(44,2,CH,GE,C'01',AND,
44,2,CH,LE,C'99',AND,
46,2,CH,GE,C'00',AND,
46,2,CH,LE,C'99',AND,
48,1,CH,EQ,C'-',AND,
49,2,CH,GE,C'01',AND,
49,2,CH,LE,C'12',AND,
51,1,CH,EQ,C'-',AND,
52,2,CH,GE,C'01',AND,
52,2,CH,LE,C'31')
/*
//INDD1 DD DSN=XX.EXTRACT.G4243,DISP=SHR
//OUTDD1 DD DSN=YY.EXTRACT.OUT,DISP=OLD
//OUTDD2 DD DSN=ZZ.EXTRACT.OMIT,DISP=OLD
//
|
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. |
|
| Back to top |
|
 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 9186 Location: 221 B Baker St
|
|
|
|
sridharxs,
Please do not double-post the same queston. The identical topic you posted a few hours earlier has been deleted.
To add just one more observation to what Craig mentioned - your code will not work for leap year.
d |
|
| Back to top |
|
 |
sridharxs
New User
Joined: 03 Jun 2005 Posts: 4 Location: India
|
|
|
|
Hi Craig and Dick Scherrer,
I am extremely sorry for double post the same question.
Is there any other way to overcome all these issues mentioned by Craig and Dick Scherrer.
I heard like there should be DATE function to handle this, but I am not sure. Please help me.
Thanks,
Sridhar. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4675 Location: San Jose, CA
|
|
|
|
| Quote: |
| I heard like there should be DATE function to handle this, but I am not sure. |
Where did you hear that? It's not true. DFSORT does not have any built-in functions to "validate" dates. |
|
| Back to top |
|
 |
sridharxs
New User
Joined: 03 Jun 2005 Posts: 4 Location: India
|
|
|
|
Hi Frank,
Could you please correct me to fulfill the requirement in the above code.
And also please let me know is there any other way to do this.
Thanks,
Sridhar |
|
| Back to top |
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 399 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? |
|
| Back to top |
|
 |
sridharxs
New User
Joined: 03 Jun 2005 Posts: 4 Location: India
|
|
|
|
Hi Skolusu,
Thank you very much. The LRECL is 191 and RECFM is FB .
I want to extract all the valid records into one file and invalid records to another file.
Cheers,
Sridhar |
|
| Back to top |
|
 |
Skolusu
DFSORT Developer
Joined: 07 Dec 2007 Posts: 399 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.
| Code: |
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your 191 LRECL file,
// DISP=SHR
//VALDATE DD SYSOUT=*
//INVALID DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(44,4,ZD,EQ,NUM),
OVERLAY=(192:44,04,ZD,MOD,+4,EDIT=(T),
193:44,04,ZD,MOD,+100,EDIT=(TTT),
196:44,04,ZD,MOD,+400,EDIT=(TTT)),HIT=NEXT),
IFTHEN=(WHEN=(196,3,ZD,EQ,0,OR,
(192,1,ZD,EQ,0,AND,193,3,ZD,GT,0)),OVERLAY=(199:C'L'),HIT=NEXT),
IFTHEN=(WHEN=(44,4,ZD,EQ,0,OR,49,2,ZD,EQ,0,OR,
052,02,ZD,EQ,0),OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(44,4,ZD,NE,NUM,OR,49,2,ZD,NE,NUM,OR,
052,02,ZD,NE,NUM),OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(48,1,CH,NE,C'-',OR,51,1,CH,NE,C'-'),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,01,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(199,01,CH,NE,C'L',AND,049,02,ZD,EQ,02,AND,
052,02,ZD,GT,28),OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(199,01,CH,EQ,C'L',AND,049,02,ZD,EQ,02,AND,
052,02,ZD,GT,29),OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,03,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,04,AND,52,02,ZD,GT,30),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,05,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,06,AND,52,02,ZD,GT,30),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,07,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,08,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,09,AND,52,02,ZD,GT,30),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,10,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,11,AND,52,02,ZD,GT,30),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(49,02,ZD,EQ,12,AND,52,02,ZD,GT,31),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=(44,04,ZD,LT,1000,OR,44,04,ZD,GT,9000),
OVERLAY=(200:C'INVALID'),HIT=NEXT),
IFTHEN=(WHEN=NONE,OVERLAY=(200:7X))
OUTFIL FNAMES=INVALID,INCLUDE=(200,7,CH,EQ,C'INVALID'),
BUILD=(01,191)
OUTFIL FNAMES=VALDATE,SAVE,BUILD=(01,191)
/*
|
Hope this helps... |
|
| Back to top |
|
 |
|
|
|