View previous topic :: View next topic
|
Author |
Message |
nmr
New User
Joined: 27 Sep 2007 Posts: 14 Location: hyderabad
|
|
|
|
the scenario is:
01 a pic x(3) comp-3.
01 b pic x(3).
if a=b+2
display""transaction accepetd"
can we compare a & b like the scenario we shown above? |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi NMR,
Quote: |
01 a pic x(3) comp-3.
01 b pic x(3).
if a=b+2
display""transaction accepetd" |
Are you doing arthematic operation on Alphanumeric Items?
Check it and let us know. |
|
Back to top |
|
|
nuthan
Active User
Joined: 26 Sep 2005 Posts: 146 Location: Bangalore
|
|
|
|
when ever u want to compare comp-3 variable with another variable first move that comp-3 to equivalent display varibale.
And post your query with good examples so that some one can provide u good solution here. |
|
Back to top |
|
|
vasanthkumarhb
Active User
Joined: 06 Sep 2007 Posts: 275 Location: Bang,iflex
|
|
|
|
Hi nmr,
Pls send the value that variable 'a' and 'b' contains,
you are not allowed to compare directly like what you posted?, because the comp-3 variable is in packed decimal format.
you can move the comp-3 variable to equivalent local variable then you can compare the variable with the local variable.
________
Regard's
Vasanth......... |
|
Back to top |
|
|
nmr
New User
Joined: 27 Sep 2007 Posts: 14 Location: hyderabad
|
|
|
|
as those variables are alphanumeric, i can assign some values to those two.
for ex: if i assign 10 to a & 8 to b, i can compre those two fields like that.
i can do like this.is it so?
i am wrong then please suggest your answer to this scenario. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I believe there is no such thing as
Code: |
01 a pic x(3) comp-3.
|
The initial post is "Can we compare a comp-3 feild with display feild". The posted example contains neither. . .
Please start over and post an example that matches the question. |
|
Back to top |
|
|
KMV
New User
Joined: 15 May 2007 Posts: 22 Location: Coimbatore
|
|
|
|
Hi,
Can we have comp-3 fields with alpha numeric??
As per my knowledge, i don't think this is possible.
Plz let me know, if we can use comp-3 field in alpha numeric.... |
|
Back to top |
|
|
nuthan
Active User
Joined: 26 Sep 2005 Posts: 146 Location: Bangalore
|
|
|
|
if the alphanumeric contains the numeric value then then it works
but if alphanumeris contains othere than numeric value then it not works, it will abend. |
|
Back to top |
|
|
jmreddymca Warnings : 1 New User
Joined: 14 Oct 2007 Posts: 29 Location: Bangalore
|
|
|
|
1st move comp-3 value to some variable then you compare that with other.please check this .Friends if any correcrtions plz let me know |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi NMR,
Change your Declaration to Numeric as like this,
Code: |
01 A PIC S9(3) COMP-3 VALUE ZEROS.
01 B PIC 9(3) VALUE ZEROS.
01 other-variable PIC 9(3) VALUE ZEROS |
Then assign values and move to other variable, Just like this,
Code: |
MOVE 111 TO A.
MOVE 109 TO B.
MOVE A TO other-variable.
IF A = B + 2
do your operation
ELSE
do your operation
END-IF. |
But above won't cover all routines, I mean if Value B is 999 then it will give wrong answer. And hence do your arthematic operation with other variable, then check your condition based on that.
Like This
Code: |
COMPUTE NEW-B = B + 2
ON SIZE ERROR route your logic. |
If you have any regards this, let us know. |
|
Back to top |
|
|
|