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
 

 

Alphanumeric comparision with Numeric

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Aravind_mf

New User


Joined: 06 Mar 2009
Posts: 13
Location: chennai

PostPosted: Thu Feb 09, 2012 3:34 am    Post subject: Alphanumeric comparision with Numeric
Reply with quote

I have a Alphanumeric variable PSSPRT-DATE X(6) ehich contains date in the format MMDDYY.

Can I use the alphanueric variable in following comparision with Numeric value?

IF PSSPRT-DATE(5:2) > 50 or do I need to use
IF PSSPRT-DATE(5:2) > '50'

The values in position 5 and 6 is always going to be numeric.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 09, 2012 3:48 am    Post subject: Reply to: Alphanumeric comparision with Numeric
Reply with quote

Yes, use '50' and you'll be fine.

What did you find in the manual?

Mr. Bill
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Thu Feb 09, 2012 4:51 am    Post subject: Re: Alphanumeric comparision with Numeric
Reply with quote

Code:

01  PSSPRT-DATE.
    05  PSSPRT-DATE-DD PIC XX.
    05  PSSPRT-DATE-MM PIC XX.
    05  PSSPRT-DATE-YY PIC XX.

01  YEAR-1950-YY PIC XX VALUE "50".

IF PSSPRT-DATE-YY GREATER THAN YEAR-1950-YY


What in heck's name is wrong with doing it like that? What's the lazy reference-modification for? Too much to type for you? I hope it is you who maintains your programs.

I guess you're not even thinking how your colleagues have done it? Let's do it six different ways and get at least some of them nearly right. Oh. They all used reference-modification as well.

It funny to do something a "fancy" obscure way, and then not know whether to code a numeric or alphanumeric literal. Doesn't that tell you you could have made your own job(s) easier?
[/code]
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Thu Feb 09, 2012 9:04 am    Post subject:
Reply with quote

the way these rookies use reference modification
you'd think they had to punch tab cards for their programs.......

5 will get you 10 that some rookie asks what a tab card is.

by the way,
reference modification automatically creates an alphanumeric (that's pic x, by the way)
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7251

PostPosted: Thu Feb 09, 2012 5:30 pm    Post subject: Reply to: Alphanumeric comparision with Numeric
Reply with quote

Code:
FD for input record.
01  A PIC X(nnn1).

FD for output record.
01 B PIC X(nnn2).

WORKING-STORAGE SECTION.
01  C COMP-3 PIC S9(18).
01  D COMP-3 PIC S9(18).
01  E COMP PIC S9(18).
01  F COMP PIC S9(18).
01  G PIC X(enough).


Assuming no floating-point numbers, I think it would be possible to construct an entire "working" program with reference-modification and a few MOVE ZEROs plus COMPUTE. Read input, do some data maninpulation, do some calculation, construct output record. Plus some IO statements, of course. Even adding some reference files, no problem. Gosh, handle saving values, tables. Just make the G big enough to cover everything needed. Can always make it bigger as you go along.

Just think how easy to get a clean compile. How little to type.

If you don't like the idea of trying to debug or amend it, why start out on that route?
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts alphanumeric sequence generation sivaprasad.gadhi COBOL Programming 6 Wed Mar 30, 2016 3:03 am


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