View previous topic :: View next topic
|
Author |
Message |
venkatarao
New User
Joined: 19 Dec 2004 Posts: 23 Location: hyderabad
|
|
|
|
Hi ,
i need to calculate Not found records percentage in my cobol program.
i have following fields:
not-found-rec-count pic 9(09).
Total-rec-count pic 9(09).
Mis-match-percent pic 9(03).
i have done below computation to get the mis-match percent.
Compute Mis-match-percent = (not-found-rec-count/Total-rec-count) * 100
But some times it is not giving percentage properly.
can any one tell me the solution for this. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
venkatarao wrote: |
But some times it is not giving percentage properly. |
Could you give an example of what you consider not proper? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please post a few sets of "input", the result of the calculation using that input and what you would rather see as the result. You might create a bit of code to do nothing but process a few sets of "counts" and display the values - no need to actually read the data, especially if the number of records might approach a billion (pic 9(9) is a very large number of possible records which is very, very rare). The size of the accumulators may also cause your calculation problems.
For starters, you should have some decimal positions defined in one or more of the fields used in the calculation. If the final result is to be without decimals, i'd suggest rounding the result. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
While waiting on some longer running processes, i did a little experiment.
If you define the first 2 fields as 9(9) and the percent field as 9(3)v999, you will get better results. When i used your definitions, i got a pct of zero.
This worked
Code: |
77 TOTL PIC S9(9) COMP-3 VALUE 100.
77 TOTH PIC S9(9) COMP-3 VALUE 80.
77 PCT PIC S9(3)V999 COMP-3 VALUE 00.
|
This failed
Code: |
77 TOTL PIC S9(9) COMP-3 VALUE 100.
77 TOTH PIC S9(9) COMP-3 VALUE 80.
77 PCT PIC S9(3) COMP-3 VALUE 00. |
The computation stayed the same
Code: |
COMPUTE PCT = (TOTH / TOTL) * 100
DISPLAY PCT.
|
|
|
Back to top |
|
|
logeswarank Warnings : 1 New User
Joined: 15 Oct 2006 Posts: 22 Location: Chennai
|
|
|
|
Hi,
Try this one.
If its wrong correct me.
Code: |
000710 3000-PROCESS.
READ INFILE-1 AT END GO TO 3500-REC-NOT.
MOVE IN-INPUT-RECORD TO WS-INPUT-RECORD.
IF WS-INP-REC-ID IS EQUAL TO 07
WRITE OU-INPUT-RECORD FROM WS-INPUT-RECORD
ELSE
COMPUTE REC-COUNT = REC-COUNT + 1
END-IF.
COMPUTE TOT-REC-COUNT = TOT-REC-COUNT + 1.
GO TO 3000-PROCESS.
3500-REC-NOT.
CLOSE INFILE-1.
CLOSE OUTFILE-1.
COMPUTE REC-COUNT-PRCNT =
(REC-COUNT / TOT-REC-COUNT) * 100.
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Try this one.
If its wrong correct me.
|
How are the percent and count fields defined? Did you run this code on your system? What result did you get? |
|
Back to top |
|
|
|