View previous topic :: View next topic
|
Author |
Message |
Sriram K
New User
Joined: 17 Feb 2009 Posts: 32 Location: Bangalore
|
|
|
|
I have input variable WS-ABC which can be numeric, alphanumeric, comp etc
I want to know how can I put a conditional expression on WS-ABC like
‘ IF WS-ABC IS NUMERIC’
‘ IF WS-ABC IS ALPHABETIC ‘
if the input variable is COMP format
I have to do this inside a COBOL program. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
There is a link to the manuals at the top of the page. Read up in the COBOL Language Reference and you will eventually find section 6.1.6.2 Class condition, which says in part
Quote: |
identifier-1
Must reference a data item described with one of the following usages:
* DISPLAY, NATIONAL, COMPUTATIONAL-3, or PACKED-DECIMAL when NUMERIC is specified
* DISPLAY-1 when DBCS or KANJI is specified
* DISPLAY or NATIONAL when ALPHABETIC, ALPHABETIC-UPPER, or ALPHABETIC-LOWER is specified
* DISPLAY when class-name is specified |
There is no reference to USAGE COMP for any of the data. This is because a COMP field is always numeric and cannot be considered alphabetic under any circumstances. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Quote: |
‘ IF WS-ABC IS ALPHABETIC ‘
if the input variable is COMP format |
Intresting - can you please show us some of the "inputs" which will go through this test? |
|
Back to top |
|
|
Sriram K
New User
Joined: 17 Feb 2009 Posts: 32 Location: Bangalore
|
|
|
|
WS-ABC is the input variable. It is alphanumeric.
I want to check whether the data in the input variable is of comp format? ( Using some conditional expression ). |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
let's see. COMP is binary - which means ANYTHING
.
or do you mean packed-decimal (which normally is COMP-3)? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
There is a link to the manuals at the top of the page. Look up COMP in the COBOL Language Reference. Any 2, 4, or 8 byte field can be treated as COMP since COMP merely means all bits are treated as a number. You cannot tell without external data (i.e., meta-data) whether any given set of bytes is alphanumeric or COMP or packed decimal -- inspection of the field cannot tell you.
The technical answer to your question
Quote: |
I want to check whether the data in the input variable is of comp format? |
is that you don't have to check -- all 2, 4, 8 byte fields are COMP by definition. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I want to check whether the data in the input variable is of comp format? ( Using some conditional expression ). |
You cannot. . .
By definition every value in the computer is of "comp format".
What requirement is there that this would fulfill? |
|
Back to top |
|
|
|