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
 

 

Can we compare a comp-3 feild with display feild

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Can we compare a comp-3 feild with display feild
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: Chennai

PostPosted: Tue Oct 16, 2007 3:39 pm    Post subject:
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    Post subject:
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: 276
Location: Bang,iflex

PostPosted: Tue Oct 16, 2007 3:47 pm    Post subject: Hi........
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    Post subject: Reply to: Can we compare a comp-3 feild with display feild
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

Site Director


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

PostPosted: Tue Oct 16, 2007 7:56 pm    Post subject:
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    Post subject: can we have comp-3 fields with alpha numeric variable???
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    Post subject:
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    Post subject: hi
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: Chennai

PostPosted: Wed Oct 17, 2007 5:52 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts Display ZEDLMSG without Pressing F1 &... anandgbe CLIST & REXX 8 Thu Dec 15, 2016 4:20 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How to display value of an exit param... lind sh CICS 2 Sun Oct 09, 2016 12:28 pm


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