View previous topic :: View next topic
|
Author |
Message |
raj_mainframe
New User
Joined: 08 Oct 2005 Posts: 6
|
|
|
|
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 |
|
|
Sridevi_C
Active User
Joined: 22 Sep 2005 Posts: 104 Location: Concord, New Hampshire, USA.
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
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 |
|
|
|