IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to validate the DATE using DFSORT/ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sridharxs

New User


Joined: 03 Jun 2005
Posts: 4
Location: Belfast, United Kingdom

PostPosted: Mon Jun 09, 2008 1:57 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jun 09, 2008 6:10 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jun 09, 2008 7:32 pm
Reply with quote

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
View user's profile Send private message
sridharxs

New User


Joined: 03 Jun 2005
Posts: 4
Location: Belfast, United Kingdom

PostPosted: Mon Jun 09, 2008 8:26 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Jun 09, 2008 8:34 pm
Reply with quote

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
View user's profile Send private message
sridharxs

New User


Joined: 03 Jun 2005
Posts: 4
Location: Belfast, United Kingdom

PostPosted: Tue Jun 10, 2008 9:34 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 10, 2008 11:08 pm
Reply with quote

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
View user's profile Send private message
sridharxs

New User


Joined: 03 Jun 2005
Posts: 4
Location: Belfast, United Kingdom

PostPosted: Wed Jun 11, 2008 5:20 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 11, 2008 10:21 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top