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
 

 

Conditional expression on comp-format?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Conditional expression on comp-format?
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: 7936
Location: Bellevue, IA

PostPosted: Wed May 06, 2009 2:51 pm    Post subject:
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

Senior Member


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

PostPosted: Wed May 06, 2009 3:41 pm    Post subject:
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    Post subject:
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    Post subject:
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: 7936
Location: Bellevue, IA

PostPosted: Wed May 06, 2009 4:11 pm    Post subject:
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

Site Director


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

PostPosted: Thu May 07, 2009 12:36 am    Post subject:
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    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 Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm


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