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
 

 

Sort card for date validation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
NikhilMF10

New User


Joined: 19 Nov 2008
Posts: 8
Location: Pune

PostPosted: Tue Feb 17, 2009 2:57 pm    Post subject: Sort card for date validation
Reply with quote

I need a sort card that can validate dates in yyyymmdd format. I want to omit all the records which are not in this format or are blank or have invalid dates.
Back to top
View user's profile Send private message

shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Tue Feb 17, 2009 6:09 pm    Post subject:
Reply with quote

NikhilMF10,

Please check with the below code.
Code:
// EXEC PGM=SORT                         
//SORTIN DD *                             
         SPACES                           
YYYYMMDD NON-NUMERIC                     
A        NON-NUMERIC                     
00001231 YEAR ZERO                       
10000031 MONTH ZERO                       
19990200 DATA ZERO                       
18781328 MONTH GREATER THAN 12           
19871232 DATE GREATER THAN 31             
19800431 DATE EQUAL TO 31 FOR APRIL       
19810631 DATE EQUAL TO 31 FOR JUNE       
19880931 DATE EQUAL TO 31 FOR SEPTEMBER   
19901131 DATE EQUAL TO 31 FOR NOVEMBER   
19900230 DATE GREATER THAN 29 FOR FEBRUARY
19000229 FEBRUARY 29 FOR NON LEAP YEAR   
20010229 FEBRUARY 29 FOR NON LEAP YEAR   
19010131 CORRECT DATE                     
19110331 CORRECT DATE         
19210531 CORRECT DATE         
19310731 CORRECT DATE         
19410831 CORRECT DATE         
19511031 CORRECT DATE         
19611231 CORRECT DATE         
19710530 CORRECT DATE         
19810630 CORRECT DATE         
19910730 CORRECT DATE         
19921130 CORRECT DATE         
20080228 CORRECT DATE         
20000229 CORRECT DATE LEAP     
20040229 CORRECT DATE LEAP     
//VALID DD SYSOUT=*           
//INVALID DD SYSOUT=*         
//SYSOUT DD SYSOUT=*           
//SYSIN DD *                   
 OPTION COPY                   
 INREC IFTHEN=(WHEN=INIT,     
            OVERLAY=(81:1,8)),                                   
       IFTHEN=(WHEN=(81,8,FS,NE,NUM,OR,                         
                     81,4,ZD,EQ,0,OR,                           
                     85,2,ZD,EQ,0,OR,                           
                     87,2,ZD,EQ,0,OR,                           
                     85,2,ZD,GT,12,OR,                           
                     87,2,ZD,GT,31,OR,                           
                    (85,2,SS,EQ,C'04,06,09,11',AND,             
                     87,2,ZD,GT,30),OR,                         
                    (85,2,ZD,EQ,02,AND,                         
                     87,2,ZD,GT,29)),                           
            OVERLAY=(92:C'0')),                                 
       IFTHEN=(WHEN=(85,2,ZD,NE,02,OR,                           
                    (85,2,ZD,EQ,02,AND,                         
                     87,2,ZD,LE,28)),                           
            OVERLAY=(92:C'1')),                                 
       IFTHEN=(WHEN=(87,2,ZD,EQ,29),                             
            OVERLAY=(89:81,4,ZD,MOD,+400,M11,LENGTH=3),HIT=NEXT),
       IFTHEN=(WHEN=(89,3,ZD,EQ,0),                             
            OVERLAY=(92:C'1')),                                 
       IFTHEN=(WHEN=(89,3,ZD,NE,0),                             
            OVERLAY=(89:81,4,ZD,MOD,+100,M11,LENGTH=3),HIT=NEXT),     
       IFTHEN=(WHEN=(89,3,ZD,EQ,0),                                   
            OVERLAY=(92:C'0')),                                       
       IFTHEN=(WHEN=(89,3,ZD,NE,0),                                   
            OVERLAY=(89:81,4,ZD,MOD,+4,M11,LENGTH=1),HIT=NEXT),       
       IFTHEN=(WHEN=(89,1,ZD,EQ,0),                                   
            OVERLAY=(92:C'1')),                                       
       IFTHEN=(WHEN=(89,1,ZD,NE,0),                                   
            OVERLAY=(92:C'0')),                                       
       IFTHEN=(WHEN=NONE,                                             
            OVERLAY=(92:C'0'))                                         
 OUTFIL FNAMES=VALID,OUTREC=(1,80),INCLUDE=(92,1,CH,EQ,C'1'),REMOVECC 
 OUTFIL FNAMES=INVALID,OUTREC=(1,80),INCLUDE=(92,1,CH,EQ,C'0'),REMOVECC

VALID
Code:
19010131 CORRECT DATE     
19110331 CORRECT DATE     
19210531 CORRECT DATE     
19310731 CORRECT DATE     
19410831 CORRECT DATE     
19511031 CORRECT DATE     
19611231 CORRECT DATE     
19710530 CORRECT DATE     
19810630 CORRECT DATE     
19910730 CORRECT DATE     
19921130 CORRECT DATE     
20080228 CORRECT DATE     
20000229 CORRECT DATE LEAP
20040229 CORRECT DATE LEAP

INVALID
Code:
         SPACES                           
YYYYMMDD NON-NUMERIC                       
A        NON-NUMERIC                       
00001231 YEAR ZERO                         
10000031 MONTH ZERO                       
19990200 DATA ZERO                         
18781328 MONTH GREATER THAN 12             
19871232 DATE GREATER THAN 31             
19800431 DATE EQUAL TO 31 FOR APRIL       
19810631 DATE EQUAL TO 31 FOR JUNE         
19880931 DATE EQUAL TO 31 FOR SEPTEMBER   
19901131 DATE EQUAL TO 31 FOR NOVEMBER     
19900230 DATE GREATER THAN 29 FOR FEBRUARY
19000229 FEBRUARY 29 FOR NON LEAP YEAR     
20010229 FEBRUARY 29 FOR NON LEAP YEAR

Thanks,
Shankar
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Tue Feb 17, 2009 11:49 pm    Post subject: Reply to: Sort card for date validation
Reply with quote

NikhilMF10,

Shankar has the right idea but you really don't need that many IFTHEN statements. The invalid date conditions are
Code:

1. If the date is NOT numeric
2. If year or month or day is zero
3. If month greater than 12
4. If day greater than 31
5. If month is (April,June,september, novemeber) and day greater than 30
6. If year is Leap and month is february and day greater than 29
7. If it is NON LEAP year and month is february and day greater than 28


Only conditions 6 and 7 need to be validated using the leap year logic, all other conditions are simple include/omit conditions

we validate the year and check it if is a leap year. Once we have the leap year indicator it is just another include/omit cond on OUTFIL

Code:


//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=(1,4,ZD,EQ,NUM),                               
  OVERLAY=(081:01,04,ZD,MOD,+4,EDIT=(T),                           
           082:01,04,ZD,MOD,+100,EDIT=(TTT),                       
           085:01,04,ZD,MOD,+400,EDIT=(TTT)),HIT=NEXT),             
  IFTHEN=(WHEN=(085,3,ZD,EQ,0,OR,(081,1,ZD,EQ,0,AND,082,3,ZD,GT,0)),
  OVERLAY=(088:C'L'))                                               
                                                                   
  SORT FIELDS=COPY                                                 
                                                                   
  OUTFIL FNAMES=INVALID,BUILD=(1,80),                               
  INCLUDE=(1,8,FS,NE,NUM,OR,                                       
           1,4,ZD,EQ,0,OR,                                         
           5,2,ZD,EQ,0,OR,                                         
           7,2,ZD,EQ,0,OR,                                         
           5,2,ZD,GT,12,OR,                                         
           7,2,ZD,GT,31,OR,                                         
           (5,2,SS,EQ,C'04,06,09,11',AND,7,2,ZD,GT,30),OR,         
           (88,1,CH,EQ,C'L',AND,5,2,ZD,EQ,2,AND,7,2,ZD,GT,29),OR,   
           (88,1,CH,EQ,C' ',AND,5,2,ZD,EQ,2,AND,7,2,ZD,GT,28))     
                                                                   
  OUTFIL FNAMES=VALID,SAVE,BUILD=(1,80)                             
/*
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 How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm


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