View previous topic :: View next topic
|
Author |
Message |
Anurag Singh
New User
Joined: 20 Jan 2008 Posts: 25 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
YOU try and tell us ! |
|
Back to top |
|
|
Anurag Singh
New User
Joined: 20 Jan 2008 Posts: 25 Location: India
|
|
|
|
I dont have resources currently to check this , if any one can check this , kindly tell the result.
TIA |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Shame on your sexism, Mr. Brenholtz; the incorrect use of the term "JCL" is not restricted to unmarried women |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Anu,
The COBOL Language Reference manual has a table showing all valid and invalid types of MOVEs. |
|
Back to top |
|
|
ajay_diaz Warnings : 1 New User
Joined: 12 Sep 2005 Posts: 28
|
|
|
|
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 |
|
|
|