View previous topic :: View next topic
|
Author |
Message |
itdsen
New User
Joined: 20 Sep 2006 Posts: 23 Location: Chennai
|
|
|
|
How to validate alphanumeric value.
i want valid first four position should be in char and next 6 position should be numeric.
eg 01 pass-no pic x(10).
input file.
aaaa111111
abaa111111
aa111234
i want validate pass no.
output file (should be in have valid input)
aaaa111111
abaa111111 |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
itdsen,
Use reference modification and check for NUMERIC or ALPHABETIC. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Code: |
01 pass-no.
05 first-four-pass-no.
10 1st-of-first-four pic x(01).
88 valid VALUES 'A' THRU 'I'
, 'J' THRU 'R'
, 'S' THRU 'Z'.
10 2nd-of-first-four pic x(01).
88 valid VALUES 'A' THRU 'I'
, 'J' THRU 'R'
, 'S' THRU 'Z'.
10 3rd-of-first-four pic x(01).
88 valid VALUES 'A' THRU 'I'
, 'J' THRU 'R'
, 'S' THRU 'Z'.
10 4th-of-first-four pic x(01).
88 valid VALUES 'A' THRU 'I'
, 'J' THRU 'R'
, 'S' THRU 'Z'.
05 last-six-pass-no Pic 9(06).
if valid in 1st-of-first-four
and
valid in 2nd-of-first-four
and
valid in 3rd-of-first-four
and
valid in 4th-of-first-four
and
last-six-pass-no numeric
then
everthing is valid
else
you don't have a valid combination.
end-if
|
alphanumeric is 'A' thru 'Z' and '0' thru '9'. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Reference modification makes the field alphanumeric so a numeric test does not work. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I verified via testing that
IF MIXED-VAR (5 : ) NUMERIC
DISPLAY 'NUMERIC PASSED'
ELSE
DISPLAY 'NUMERIC FAILED'
END-IF.
displays NUMERIC PASSED when executed. There's no reason reference modification fields can't be used in numeric tests as long as the underlying data structure doesn't contain elementary signed items. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Robert,
Quote: |
There's no reason reference modification fields can't be used in numeric tests as long as the underlying data structure doesn't contain elementary signed items. |
Good piece of info. Thanks. |
|
Back to top |
|
|
star_dhruv2000
New User
Joined: 03 Nov 2006 Posts: 87 Location: Plymouth, MN USA
|
|
|
|
Code: |
01 PASS-NO.
05 CHAR-VAL PIC X(04).
05 INT-VAL PIC 9(06).
IF CHAR-VAL IS ALPHABETIC THEN
IMPERATIVE STATEMENTS..
END-IF.
IF INT-VAL IS NUMERIC THEN
IMPERATIVE STATEMENTS...
END-IF.
|
Cheers
Happy Coding |
|
Back to top |
|
|
Max Payne
New User
Joined: 13 Dec 2007 Posts: 10 Location: Shanghai
|
|
|
|
Quote: |
IF pass-no(1:4) IS ALPHABETIC AND pass-no(5 IS NUMERIC
DISPLAY 'WRITE OUT'
ELSE
DISPLAY 'OMIT'
END-IF. |
|
|
Back to top |
|
|
|