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

Alphanumeric comparision with Numeric


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Feb 09, 2012 3:48 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 09, 2012 4:51 am
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Feb 09, 2012 5:30 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts convert alphanumeric PIC X(02) to hex... COBOL Programming 3
Search our Forums:

Back to Top