View previous topic :: View next topic |
Author |
Message |
ranga_subham Intermediate
Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Tue Apr 24, 2012 8:56 am Post subject: Checking date format |
|
|
Hi,
Request you to let me know how to check whether received date format is correct or not using SORT. Our file has records like this in the below given format and this should be checked for correct format only (CCYY-MM-DD)
Input File:
Code: |
9999-99-99
2005-01-12
2007-09-18
2006/11-21
|
Output:
Code: |
9999-99-99
2005-01-12
2007-09-18
|
The last entry "2006/11-21" should be omitted because it has "/" in 5th position.
Please help.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard |
|
Back to top |
|
|
Sqlcode Intermediate
Joined: 15 Dec 2006 Posts: 157 Topics: 38
|
Posted: Tue Apr 24, 2012 9:43 am Post subject: |
|
|
ranga_subham,
If you really meant to check any other values than '-' in the 5th and 8th position, shouldn't you omit such records? OR did you mean to check for valid date values as well?
Something like below?
Code: | //STEP0001 EXEC PGM=SORT
//SORTIN DD *
9999-99-99
2005-01-12
2007-09-18
2006/11-21
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(5,1,CH,NE,C'-',OR,8,1,CH,NE,C'-')
/*
//SYSOUT DD SYSOUT=*
//* |
OUTPUT
Code: | 9999-99-99
2005-01-12
2007-09-18 |
Thanks, |
|
Back to top |
|
|
ranga_subham Intermediate
Joined: 31 Jan 2006 Posts: 255 Topics: 72
|
Posted: Thu Apr 26, 2012 7:24 am Post subject: reply |
|
|
sqlcode, actually, I want to correct the data by replacing any other character with "-" in those positions so that our process does not omit but consider them. Right now, its been handled by program and we report it back saying error records.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Apr 26, 2012 10:28 am Post subject: Re: reply |
|
|
ranga_subham wrote: | sqlcode, actually, I want to correct the data by replacing any other character with "-" in those positions so that our process does not omit but consider them. Right now, its been handled by program and we report it back saying error records.
Thanks. |
If your intention is to just replace the character, use the following DFSORT JCL
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
9999-99-99
2005-01-12
2007-09-18
----+----1----+----2----+----3-
2006/11-21
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(5:C'-',8:C'-')
//* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|