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

Comparison of Alphanumeric to Comp variable


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Dec 19, 2009 7:40 pm
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Dec 19, 2009 10:15 pm
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: 6966
Location: porcelain throne

PostPosted: Sat Dec 19, 2009 11:15 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sat Dec 19, 2009 11:27 pm
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: 6966
Location: porcelain throne

PostPosted: Sun Dec 20, 2009 1:07 am
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: 1788
Location: Bloomington, IL

PostPosted: Sun Dec 20, 2009 6:42 am
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top