View previous topic :: View next topic
|
Author |
Message |
Rick Silvers
New User
Joined: 31 Mar 2012 Posts: 9 Location: USA
|
|
|
|
Hi
I need to validate value in 4 fields in an input file, can I do this with sort or ICETOOL and set step RC if a field contains incorrect value ?
date1, date2, date3, blance_amount
date1 is format YYYYMM
date2 is format YYYYMMDD
date3 is format YYYYMMDD
blance_format is format 999999999 |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Rick,
Most probably yes. What kind of validation do you need to perform on these fields? Can you provide details on each of those. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
Back to top |
|
|
Rick Silvers
New User
Joined: 31 Mar 2012 Posts: 9 Location: USA
|
|
|
|
Arun Raj wrote: |
Rick,
Most probably yes. What kind of validation do you need to perform on these fields? Can you provide details on each of those. |
date1, date2, date3, blance_amount
date1 is format YYYYMM and can be only YYYYMM
date2 is format YYYYMMDD and can be only YYYYMMDD
date3 is format YYYYMMDD and can be only YYYYMMDD
blance_format is format 999999999 and needs to be numeric, no characters or . (decimals) |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Rick,
You could use the 'NUM' function to check for numeric, but for date validation there might not be built-in functions. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Rick,
A good friend and a mentor of mine pointed out that we could validate any input date by merely applying a date conversion on the input date field.
If the input date is invalid, the output date from the conversion would have asterisks ('*').
Ran a test and here is what I got.
Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
20170228
20170229
20180229
20190229
20200229
20170332
20170500
20171301
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(10:1,8,Y4T,TOGREG=Y4T) |
SORTOUT had
Code: |
20170228 20170228
20170229 ********
20180229 ********
20190229 ********
20200229 20200229
20170332 ********
20170500 ********
20171301 ******** |
For your requirement, you could do a similar conversion for each input date field and then check the resultant date for numeric data (using NUM), to achieve what you want.
For the first date field - date1 (YYMM), you might want to suffix '01' before the conversion.
Good luck! |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2010 Location: USA
|
|
|
|
Arun Raj wrote: |
Rick,
A good friend and a mentor of mine pointed out that we could validate any input date by merely applying a date conversion on the input date field.
If the input date is invalid, the output date from the conversion would have asterisks ('*'). |
Good idea. Thanks for sharing it! |
|
Back to top |
|
|
|