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
 

 

Display percentage value in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Aug 22, 2011 9:53 am    Post subject: Display percentage value in cobol
Reply with quote

Dear All ,

I am encountering a problem while displaying a percentage value in a report.

Below are the details:
WS-COMPLETION-PERCENTAGE PIC 9(3)V9.
REPT-REJ-PER-CKI PIC ZZ9.9.

I am calculating the percentage and putting that value in WS-COMPLETION-PERCENTAGE variable.

Now ,While expediting the code , value calculated for WS-COMPLETION-PERCENTAGE 007.4 which is correct.

However when displayed it it showing :
WS-COMPLETION-PERCENTAGE:0074

I moved the above value into REPT-REJ-PER-CKI and the value getting displayed is :0.7

I need to display the correct percentage value in the report i.e 0007.4.

Can someone please advise what can be done to achieve desired result.

Regards,
Shweta
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: Mon Aug 22, 2011 10:12 am    Post subject:
Reply with quote

Hello,

Code:
WS-COMPLETION-PERCENTAGE PIC 9(3)V9.
You have specified an implied decimal - which is what you want for calculatoins.

You need to add another field for the displayed output that has an edited picture. Use pic 999.9 if you want the leading zeros or zzz.9 if you want the leading zeros suppressed.
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Aug 22, 2011 10:18 am    Post subject: Reply to: Display percentage value in cobol
Reply with quote

Hi Dick ,

While displaying in a report I am using REPT-REJ-PER-CKI variable which is of PIC ZZ9.9 and it is giving me value 0.7 wherease I need 0007.4 to be displayed.


Regards,
Shweta.
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: Mon Aug 22, 2011 10:21 am    Post subject:
Reply with quote

Hello,

When someone posts a solution, suggest you follow it. . . icon_confused.gif

Reread my previous post and change your pic accordingly. . .
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Aug 22, 2011 10:33 am    Post subject: Reply to: Display percentage value in cobol
Reply with quote

Hi Dick ,

May be I didn't put my phrase in correct form.

After doing percentage calculation , I have moved WS-COMPLETION-PERCENTAGE to REPT-REJ-PER-CKI(which is of PIC zz9.9)

I have used edited pic variable while displaying in report which is REPT-REJ-PER-CKI as mentioned in my first post.

Please let me know if i am misunderstood your suggestion.

Regards,
Shweta
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 22, 2011 10:51 am    Post subject: Re: Display percentage value in cobol
Reply with quote

Shweta12j wrote:
[...]WS-COMPLETION-PERCENTAGE PIC 9(3)V9.
REPT-REJ-PER-CKI PIC ZZ9.9.

[...]


Why would a "completion percentage" go to a report field called "rej-per-cki"?
Back to top
View user's profile Send private message
Shweta12j

New User


Joined: 10 May 2010
Posts: 32
Location: Mumbai

PostPosted: Mon Aug 22, 2011 10:58 am    Post subject: Reply to: Display percentage value in cobol
Reply with quote

Hi Bill ,

I am using WS-COMPLETION-PERCENTAGE variable for calculation of percentage in a code and by moving it's value to REPT-REJ-PER-CKI , I am trying to display the same percentage value in a Percentage report.

Regards,
Shweta.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Aug 22, 2011 11:19 am    Post subject:
Reply with quote

Hi Shweta,

Why would you do that? You've given your data better names than is usual here. "REJ" looks like "rejection", "rejection" doesn't look like "completion".

For what you have shown, if those are the fields used, with the values used at the time, you should get 7.4 in your report.

So, either the definitions are wrong or the values are wrong, or the reported result is wrong. Or the fields are the wrong ones at some point.

0074 in PIC 999V9 moved to PIC ZZ9.9 will get you blank, blank, 7.4 every time. Every time. It is a computer, that it what happens.

So, the problem as presented by you does not exist, so you have to work back and find where something is not as you have explained it. At that point, you may well know the answer yourself, if not, update us.
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 Aug 23, 2011 9:08 am    Post subject:
Reply with quote

Hello,

Quote:
Please let me know if i am misunderstood your suggestion.

Yes, you misunderstood. . .

Quote:
You need to add another field for the displayed output that has an edited picture. Use pic 999.9 if you want the leading zeros or zzz.9 if you want the leading zeros suppressed.
If you wanted the leading zeros, why did you suppress them? ZZZ.9 suppresses leading zeros.

One of your replies also mentions 0007.4 - you need to increase the length if you want 4 positions in front of the decimal.

As has been mentioned, you need to use meaningful data names.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Tue Aug 23, 2011 1:44 pm    Post subject:
Reply with quote

First problem, you saw 0.7 instead of 7.4
according to the information you provided. you should have seen 7.4
Have you checked that you are really doing what you say you are doing ?
what is your status right now?

Second, you got us mixed with zz9.9 and 0007.4 and 0.7
Please be accurate about the format you want to see.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 961
Location: Richmond, Virginia

PostPosted: Tue Aug 23, 2011 5:23 pm    Post subject:
Reply with quote

If you just bite the bullet and on your first post show your code and results (hex too) exactly by pasting within code tags, you would not need to keep saying what you (think you) are doing.

Whether you are right or wrong - just communicate clearly the first time.

No one gets paid a commission on the number of attempted replies to pick your brain.

The rest of us are eagerly wading thru this mess looking for the answer.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 642
Location: Whitby, ON, Canada

PostPosted: Tue Aug 23, 2011 6:05 pm    Post subject:
Reply with quote

When a programmer says "This is what I coded", what he really means is: "This is what I thought I coded", or, "This is what I meant to code." icon_confused.gif
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Aug 23, 2011 7:34 pm    Post subject:
Reply with quote

decimal point is comma ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Tue Aug 23, 2011 9:45 pm    Post subject: Reply to: Display percentage value in cobol
Reply with quote

Very nice, Guy. That would do it.

Code:

A PIC ZZ.9.
B PIC 99.9.
C PIC 999V9.

DIVIDE 74 BY 10 GIVING C
MOVE C TO A
          B


C would have 0074 with an implied decimal place between the 7 and the 4, everything unaffected so far by DECIMAL-POINT IS COMMA.

However, for A, the decimal place is after the right-most position, with a COMMA, disguised (to the human eye) as a PERIOD/FULLSTOP/DECIMAL-POINT. So A gets
Code:
blank, blank point 7


Similarly, with B

Code:
00.7


The "dot" that we can see (in my example) is actually taking on the work of a comma, like instead of 123,456,789.11 which we do in Britainia, 123.456.789,11 like in places in Europe.

I'll remember that Guy. You seen it before?

TS is long gone, we'll never know for sure, but it definitely fits. Who would think, pick up a program at a new site, make the change, not notice all the other data definitions (OK, thin on that one) and definitely not look for DECIMAL-POINT IS COMMA.

EDIT: This means I was wrong in my earlier post. There is a(n) (almost) reasonable way of screwing it up.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Wed Aug 24, 2011 4:38 pm    Post subject:
Reply with quote

I did see it before : outsourcing.
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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