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

Comparison of Pack-Decimal Field –Comp-3


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

New User


Joined: 27 Mar 2006
Posts: 31

PostPosted: Thu Aug 26, 2010 12:06 am
Reply with quote

Hi,

Hi,

Could any one please let me know how can I compare a comp-3 field ? I want to compare the value of

PIC S9(5)V9(5) COMP-3. with 999999

IF IT IS > 999999

THEN I want to subtract 1000000 , but its not working for me , because I know I can’t compare a comp-3 field with a number .

Could any one please help me to implement this change ?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 26, 2010 12:15 am
Reply with quote

harry wrote:

PIC S9(5)V9(5) COMP-3. with 999999

IF IT IS > 999999




Your compare is matching 999999.00000 with a field that is at the most 99999.99999 so it could never be greater. When you are comparing with a numeric literal you need to consider the decimal point. RTFM.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 26, 2010 12:15 am
Reply with quote

Hello,

Quote:
but its not working for me , because I know I can’t compare a comp-3 field with a number
Of course you can. . . In fact, about the only compare that makes logical sense is to compare a comp-3 field with a number. . .

You need to post the variables and procedure code that is not working and mention what problem(s) you encountered.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 26, 2010 12:16 am
Reply with quote

Quote:
because I know I can’t compare a comp-3 field with a number
Fortunately -- or not -- what you know is completely, absolutely, totally wrong. This has been discussed a number of times on this forum -- search the forum.
Back to top
View user's profile Send private message
harry

New User


Joined: 27 Mar 2006
Posts: 31

PostPosted: Thu Aug 26, 2010 12:29 am
Reply with quote

Hi Mr. dick scherrer,

This is what i am using :

WS-ORDER-NO PIC S9(5)V9(5) COMP-3.
*******************************************
IF WS-ORDER-NO > 999999.00000

COMPUTE WS-ORDER-NO-OUT = (1000000 - WS-ORDER-NO)

ELSE

MOVE WS-ORDER-NO TO WS-ORDER-NO-OUT
END-IF.

But this logic also not working ,
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Aug 26, 2010 12:33 am
Reply with quote

WS-ORDER-NO PIC S9(5)V9(5) COMP-3.
*******************************************
IF WS-ORDER-NO > 999999.00000


S9(5)v9(5) can never be greater then 999999.00000 the max for that field is 99999.99999!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 26, 2010 12:38 am
Reply with quote

Hello,

Quote:
IF WS-ORDER-NO > 999999.00000
Why might an order number have a decimal? Why are there more digits to the left of the decimal in the literal than is possible for the field?

Why is there a computation for the "next" order number?

If this "order number" is to be the key to database tables, vsam files, or even sequential data, this scheme will result in many long-term problems. . .
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 26, 2010 12:38 am
Reply with quote

the largest value WS-ORDER-NO PIC S9(5)V9(5) COMP-3 can contain is:
99999.99999
that's 5 - 9's decimal point and 5 9's.

or
ninety-nine thousand nine hundred ninety-nine
point
ninety-nine thousand nine hundred ninety-nine one-hundred-thousands.
Back to top
View user's profile Send private message
harry

New User


Joined: 27 Mar 2006
Posts: 31

PostPosted: Thu Aug 26, 2010 12:58 am
Reply with quote

dick scherrer, you were talking about long term problems...I know but no body here listen to any thing ...there are so many loop holes but while system design no body came together and all these problem came in where order numbers are defined as comp-3...

------------------------------------------
meanwhile i tried all the option to compare a comp-3 field but still no success ...

1> Order-number > 99999.99999 also not working .
2>tried to move order-number to pic 9 (06) because s9(5)v9(5) is 6 bytes and then tried to compare the new 9(06) field with 999999 but still not working ..

Please advise some way to resolve this issue .

Thanks
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Thu Aug 26, 2010 1:05 am
Reply with quote

all the copyright credit to dbzTHEdinosauer icon_biggrin.gif
the largest value WS-ORDER-NO PIC S9(5)V9(5) COMP-3 can contain is:
99999.99999
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 26, 2010 1:10 am
Reply with quote

Harry,

let's try this another way.

you have a 5 pound bag. it can only hold 5 pounds or less of something.

do not expect that you can fill the 5 pound bag and expect it to weigh more than 5 pounds.

you have to expect the 5 pound bag to weigh less than 5 pounds.

so trying to see if the 5 pound bag weighs 6 pounds, you will always receive 'FALSE'.

the same applies to your comparision.
order-number can never be greater than 99999.99999.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 26, 2010 1:15 am
Reply with quote

Your problem is NOT a COBOL issue.

Your problem is a mathematical impossibility: an IF test comparing a value with 5 digits in front of the decimal will not, under any circumstances, be greater than or equal to one million -- which is what your comparison is checking.

Since COBOL supports operations on numeric edited fields, you can MOVE your data to a PIC 9(06)V9(05) variable and use that for comparison if you want. However, unless you do calculations on the 6-digit variable, since a 5-digit variable value will always be less than one hundred thousand, just moving it to a 6-digit variable will not change that. Comparing it to one million will always come back less -- always.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Thu Aug 26, 2010 3:56 am
Reply with quote

Please look at this and tell me if I have ASSUMED correctly:

It sounds as if you have the task of issuing NEW Order numbers.
AND when the Order number EXCEEDS your limit of 99999.00000,
you are trying to get the ORDER-NUMBER to begin at the number
00001.00000.

If I am correct then TRY THIS:

WS-ORDER-NO PIC S9(5)V9(5) COMP-3.
*******************************************
IF WS-ORDER-NO = 99999.00000
ADD 1 TO WS-ORDER-NO.
MOVE WS-ORDER-NO TO WS-ORDER-NO-OUT.

IF MY ASSUMPTION IS -INCORRECT-- -- I hope someone else can give you your solution.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 26, 2010 4:18 am
Reply with quote

*Sigh*

I suppose you were more focused on posting an answer rather that reading thru the topic and understanding the conversation thus far . . .

If 5 digits is the maximum possible before the decimal why would you suggest using 999999.0000. . . icon_confused.gif
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Thu Aug 26, 2010 5:03 am
Reply with quote

Thats my MISTAKE - I meant to type 5 intergers and 5 decimals. very sorry 99999.00000
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 26, 2010 5:16 am
Reply with quote

Please check and make sure i corrected the post properly.

If all is well, i'll delete our last couple of posts. . .

Also, i believe the code shown will give a new number of 00000.00000 . . .

d
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 Help required to reset decimal points... DFSORT/ICETOOL 8
No new posts Unable to interpret a hex value to De... COBOL Programming 4
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts small int to zoned decimal conversion DFSORT/ICETOOL 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top