Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 8165
Location: East Dubuque, Illinois, USA

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: 6968
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: 8165
Location: East Dubuque, Illinois, USA

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 Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us