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

Cobol reporting program to truncate


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

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Mon Jul 18, 2011 12:22 pm
Reply with quote

Hi,

I have one field which is an amt field which is 6 decimal points.
Requirement is

when I am writing the total amt , I have to sum up all the 6 decimal amt values and truncate it to a 2 decimal value.
Total is a 2 decimal field.

this is a reporting program.

Please suggest.


Current code is

03 COL 3 'TOTAL UNDRAWN'.
03 COL +12 PIC ZZZ,ZZZ,ZZZ,ZZ9.99-
SUM Ws-AMT.

eventhough ws-amt is 6 decimal since they have code decimal 2 in the picture caluse it is not giving proper result.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 18, 2011 12:35 pm
Reply with quote

sandhyaimmadi wrote:
Hi,

I have one field which is an amt field which is 6 decimal points.
Requirement is

when I am writing the total amt , I have to sum up all the 6 decimal amt values and truncate it to a 2 decimal value.
Total is a 2 decimal field.

this is a reporting program.

Please suggest.


Current code is

03 COL 3 'TOTAL UNDRAWN'.
03 COL +12 PIC ZZZ,ZZZ,ZZZ,ZZ9.99-
SUM Ws-AMT.

eventhough ws-amt is 6 decimal since they have code decimal 2 in the picture caluse it is not giving proper result.


Are you using the Cobol Report Writer?

What do you mean by "it is not giving proper result"? Give an example, please, of some lines and what this does "give" for those.

Why do you want to "truncate", and can I have the little bits that fall off the end when you do that please?
Back to top
View user's profile Send private message
sandhyaimmadi

New User


Joined: 18 Aug 2008
Posts: 50
Location: Bangalore

PostPosted: Mon Jul 18, 2011 12:49 pm
Reply with quote

yeah we are using report writer.

Below is the sample

CALC UNDRAWN AMT
602.787944

CALC UNDRAWN AMT
51.509041

TOTAL UNDRAWN 654.28


Actual result should be 654.29
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 18, 2011 12:54 pm
Reply with quote

Interesting.

Perhaps SUM is "doing something" by default? Have you checked in a manual what it says for how SUM behaves?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jul 18, 2011 1:00 pm
Reply with quote

another one who does not bother to read the manual or even think.

to arrive at 654.29, one would have to accumulate to 6 dp,
then move to 2 dp with a round.

since the total is being accumulated in a 2 dp, the truncation is not providing the rounding of the 3rd and 4th dp.

you want the effect of all 6 dp, accumulate at 6 dp.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 18, 2011 1:07 pm
Reply with quote

What dbz describes is/looks like what is happening, even though your amount has six decimal places.

Look at your other examples, and truncate the detail lines (mentally) to check your total lines. I expect they all then make sense.

So, in how you get from six to truncating at two for the SUM you have to look in the manual and review your code.
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top