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

Conditional expression on comp-format?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sriram K

New User


Joined: 17 Feb 2009
Posts: 32
Location: Bangalore

PostPosted: Wed May 06, 2009 12:33 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed May 06, 2009 2:51 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed May 06, 2009 3:41 pm
Reply with quote

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
View user's profile Send private message
Sriram K

New User


Joined: 17 Feb 2009
Posts: 32
Location: Bangalore

PostPosted: Wed May 06, 2009 3:55 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 06, 2009 4:06 pm
Reply with quote

let's see. COMP is binary - which means ANYTHING
Quote:
is of comp format
.

or do you mean packed-decimal (which normally is COMP-3)?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed May 06, 2009 4:11 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu May 07, 2009 12:36 am
Reply with quote

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
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 Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
Search our Forums:

Back to Top