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
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
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


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