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
 

 

Alphanumeric test in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
raj_mainframe

New User


Joined: 08 Oct 2005
Posts: 6

PostPosted: Sat Oct 22, 2005 5:54 pm    Post subject: Alphanumeric test in COBOL
Reply with quote

Suppose variable A is Alphanumeric

Working-Storage Section.

01 A PIC X(3).

Procedure Division.

IF A EQUAL 456 then.........................


Is the above if test is right or do i have to write like this
IF A EQUAL '456'

Please tell is it possible to test an alphanumeric variable with some numeric constant without giving quotes?
Back to top
View user's profile Send private message

Sridevi_C

Active User


Joined: 22 Sep 2005
Posts: 104
Location: Concord, New Hampshire, USA.

PostPosted: Sat Oct 22, 2005 8:03 pm    Post subject:
Reply with quote

No,you can't omit the quotes. If datatype is alphanumeric,then no matter what it contains,numeric or alphabetic or mixed.Quotes is a MUST.Hence,
IF A = '456' THEN......
Regards,
Sridevi.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Oct 22, 2005 9:07 pm    Post subject:
Reply with quote

Hi Raj,

In the later versions of COBOL the need for quotes when referencing numerics for an A/N field was dropped.

I think COBOLII was the 1st release that allowed it.
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Mon Oct 24, 2005 11:28 am    Post subject: Re: Alpha numeric test in COBOL
Reply with quote

Yes, I do agree with mmwife.
You need not to have quotes when you have only numerics in your data for alphanumeric data-item, in the latest versions.
For example,
01 WS-STAT-CODE x(01).

Evaluate WS-STAT-CODE
WHEN 1
WHEN 2
End-EVALUATE

(or)

Evaluate WS-STAT-CODE
WHEN "1"
WHEN "2"
End-EVALUATE

Above two works the same way....

Cheers,
Kumar.
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


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