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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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