Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Cobol reporting program to truncate

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Cobol reporting program to truncate
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Jul 18, 2011 12:35 pm    Post subject: Re: cobol reporting program
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    Post subject: cobol reporting program
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Jul 18, 2011 12:54 pm    Post subject: Reply to: cobol reporting program
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: 6970
Location: porcelain throne

PostPosted: Mon Jul 18, 2011 1:00 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Mon Jul 18, 2011 1:07 pm    Post subject:
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    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 The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us