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
 

 

Comparison of Pack-Decimal Field –Comp-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Comparison of Pack-Decimal Field –Comp-3
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    Post subject: Re: Comparison of Pack-Decimal Field –Comp-3
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

Site Director


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

PostPosted: Thu Aug 26, 2010 12:15 am    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Thu Aug 26, 2010 12:16 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Aug 26, 2010 12:38 am    Post subject:
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    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Aug 26, 2010 1:05 am    Post subject: Reply to: Comparison of Pack-Decimal Field –Comp-3
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    Post subject:
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: 7914
Location: Bellevue, IA

PostPosted: Thu Aug 26, 2010 1:15 am    Post subject:
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    Post subject: Reply to: Comparison of Pack-Decimal Field –Comp-3
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

Site Director


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

PostPosted: Thu Aug 26, 2010 4:18 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Aug 26, 2010 5:16 am    Post subject: Reply to: Comparison of Pack-Decimal Field –Comp-3
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    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 Performing arithmetic on input field zh_lad DFSORT/ICETOOL 24 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts CICS NEW SIT PARAMETERS CICS BEHAVIOR... Kyle Carroll CICS 0 Fri Nov 04, 2016 11:55 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


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