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

Alphanumeric test in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top