IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how to validate Alphanumeric filed


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
itdsen

New User


Joined: 20 Sep 2006
Posts: 23
Location: Chennai

PostPosted: Wed Jun 11, 2008 6:35 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Wed Jun 11, 2008 6:52 pm
Reply with quote

itdsen,

Use reference modification and check for NUMERIC or ALPHABETIC.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 6:56 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 6:57 pm
Reply with quote

Reference modification makes the field alphanumeric so a numeric test does not work.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Jun 11, 2008 9:01 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Jun 12, 2008 2:38 am
Reply with quote

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
View user's profile Send private message
star_dhruv2000

New User


Joined: 03 Nov 2006
Posts: 87
Location: Plymouth, MN USA

PostPosted: Sat Jun 14, 2008 6:03 pm
Reply with quote

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 icon_biggrin.gif
Happy Coding
Back to top
View user's profile Send private message
Max Payne

New User


Joined: 13 Dec 2007
Posts: 10
Location: Shanghai

PostPosted: Tue Jun 24, 2008 1:52 pm
Reply with quote

Quote:

IF pass-no(1:4) IS ALPHABETIC AND pass-no(5icon_smile.gif IS NUMERIC
DISPLAY 'WRITE OUT'
ELSE
DISPLAY 'OMIT'
END-IF.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
No new posts Need to validate the field using cobol COBOL Programming 4
No new posts JSONVALID to validate the JSON PL/I & Assembler 4
No new posts Write a current record plus previous ... DFSORT/ICETOOL 4
No new posts Packed decimal to Alphanumeric COBOL Programming 2
Search our Forums:

Back to Top