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

Can we compare a comp-3 feild with display feild


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Tue Oct 16, 2007 3:33 pm
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 16, 2007 3:39 pm
Reply with quote

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
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Tue Oct 16, 2007 3:45 pm
Reply with quote

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
View user's profile Send private message
vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 275
Location: Bang,iflex

PostPosted: Tue Oct 16, 2007 3:47 pm
Reply with quote

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......... icon_smile.gif
Back to top
View user's profile Send private message
nmr

New User


Joined: 27 Sep 2007
Posts: 14
Location: hyderabad

PostPosted: Tue Oct 16, 2007 3:48 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 16, 2007 7:56 pm
Reply with quote

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
View user's profile Send private message
KMV

New User


Joined: 15 May 2007
Posts: 22
Location: Coimbatore

PostPosted: Wed Oct 17, 2007 9:32 am
Reply with quote

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
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Wed Oct 17, 2007 10:18 am
Reply with quote

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
View user's profile Send private message
jmreddymca
Warnings : 1

New User


Joined: 14 Oct 2007
Posts: 29
Location: Bangalore

PostPosted: Wed Oct 17, 2007 5:16 pm
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Wed Oct 17, 2007 5:52 pm
Reply with quote

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
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 Compare only first records of the fil... SYNCSORT 7
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Compare two files with a key and writ... SYNCSORT 3
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts How to compare two rows of same table DB2 11
Search our Forums:

Back to Top