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
 

 

how to validate Alphanumeric filed

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: how to validate Alphanumeric filed
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: 1288
Location: Chennai, India

PostPosted: Wed Jun 11, 2008 6:52 pm    Post subject: Reply to: how to validate Alphanumeric filed
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: 6968
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 6:56 pm    Post subject:
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: 6968
Location: porcelain throne

PostPosted: Wed Jun 11, 2008 6:57 pm    Post subject:
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: 8119
Location: East Dubuque, Illinois, USA

PostPosted: Wed Jun 11, 2008 9:01 pm    Post subject: Reply to: how to validate Alphanumeric filed
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: 1288
Location: Chennai, India

PostPosted: Thu Jun 12, 2008 2:38 am    Post subject: Reply to: how to validate Alphanumeric filed
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts How can we have the varying lenth of ... Gunapala CN DFSORT/ICETOOL 6 Fri Oct 14, 2016 7:31 pm


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