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
 

 

Comparison of Alphanumeric to Comp variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
Anurag Singh

New User


Joined: 20 Jan 2008
Posts: 25
Location: India

PostPosted: Sat Dec 19, 2009 7:16 pm    Post subject: Comparison of Alphanumeric to Comp variable
Reply with quote

Please suggest , whether the below given expression will be executable in COBOL:

LAyout of variable:
WS-A Pic x(4)
WS-B Pic s9(4) comp-3

Both variables have value "1234"

Now


IF WS-A = WS-B
Perform 2000-para-a
else
perform 2000-para-b


What will be the answer and why ?
can we compare both the variables?
whether Para-a will be performed of Para-b?
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Sat Dec 19, 2009 7:40 pm    Post subject: Reply to: Comparison of Alphanumeric to Comp variable
Reply with quote

YOU try and tell us !
Back to top
View user's profile Send private message
Anurag Singh

New User


Joined: 20 Jan 2008
Posts: 25
Location: India

PostPosted: Sat Dec 19, 2009 8:08 pm    Post subject: Reply to: Comparison of Alphanumeric to Comp variable
Reply with quote

I dont have resources currently to check this , if any one can check this , kindly tell the result.

TIA
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: Sat Dec 19, 2009 10:15 pm    Post subject: Reply to: Comparison of Alphanumeric to Comp variable
Reply with quote

Redefine WS-A as PIC 9(04) and then compare. The compiler will most likely "Pack" the redefined WS-A and ensure a "C" sign-nibble, then issue a "Compare Pack" instruction.

Some versions of the COBOL compiler will "Pack" the PIC X(04) version of WS-A and ensure the "C" sign-nibble, but you'll always be correct using the redefined PIC 9(04) definition.

I don't have a means to test this but, using the PIC 9(04) redefinition of WS-A will ensure a result of either an EQUAL or NOT EQUAL condition, providing WS-A resolves itself to a valid "Packed-Decimal" value. Otherwise, you'll get a S0C7 Data-Exception.

Note that your post indicates Alphanumeric to COMP comparison, but you're actually comparing Alphanumeric to Packed-Decimal (COMP-3).

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sat Dec 19, 2009 11:15 pm    Post subject:
Reply with quote

Quote:
Note that your post indicates Alphanumeric to COMP comparison, but you're actually comparing Alphanumeric to Packed-Decimal (COMP-3).


Bill, what are words? Few posters have any idea what they are talking about, much less the proper vocabulary to express their thoughts.
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: Sat Dec 19, 2009 11:27 pm    Post subject: Reply to: Comparison of Alphanumeric to Comp variable
Reply with quote

Dick,

I understand that terminology sometimes intimidates. But, my method for madness was for the OP to possibly research this on their own time and not to impose on others.

After this post had been moved to the proper forum, I realized that I may have given TMI.

But, some information is better than none and (IMHO) it's best to educate one's self in their area of expertise, rather than to rely on others to spoon feed it to them, because they'll learn nothing except to meld themselves into some sort of "Entitlement".

Bill
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Sun Dec 20, 2009 1:07 am    Post subject:
Reply with quote

Sorry Bill, you misinterpreted my comment.

I am ever mean-spirited in my posts because people post without
using the proper terminology - without which one can not attain a decent level of subject understanding.

the continual miss-use of the term JCL,
the obvious (and sometime not obvious) typo's are just indicative of not 'previewing' their work.

your posts are most informative, and don't ever think that I am being critical of your efforts.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1754
Location: Bloomington, IL

PostPosted: Sun Dec 20, 2009 6:42 am    Post subject:
Reply with quote

Shame on your sexism, Mr. Brenholtz; the incorrect use of the term "JCL" is not restricted to unmarried women icon_wink.gif
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sun Dec 20, 2009 7:31 am    Post subject:
Reply with quote

Anu,
The COBOL Language Reference manual has a table showing all valid and invalid types of MOVEs.
Back to top
View user's profile Send private message
ajay_diaz
Warnings : 1

New User


Joined: 12 Sep 2005
Posts: 28

PostPosted: Tue Apr 27, 2010 5:35 pm    Post subject: Reply to: Comparison of Alphanumeric to Comp variable
Reply with quote

Pardon me for replying to this post now (after 4 months!!). But I thought it might be useful for others in future.
I tried to test the program but the program couldn't even be compiled. It gave error message saying "The comparison of packed and alpha-numeric is discarded".
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
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


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