Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 
How to validate the DATE using DFSORT/ICETOOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to validate the DATE using DFSORT/ICETOOL
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    Post subject: Re: How to validate the DATE using DFSORT/ICETOOL
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

Site Director


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

PostPosted: Mon Jun 09, 2008 7:32 pm    Post subject: Reply to: How to validate the DATE using DFSORT/ICETOOL
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    Post subject: Reply to: How to validate the DATE using DFSORT/ICETOOL
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 Moderator


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

PostPosted: Mon Jun 09, 2008 8:34 pm    Post subject:
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    Post subject: How to validate the DATE using DFSORT/ICETOOL
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    Post subject:
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    Post subject: Reply to: How to validate the DATE using DFSORT/ICETOOL
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Using ICETOOL, how we can seperate th... bshkris SYNCSORT 5 Tue May 09, 2017 8:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us