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
 

 

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: 7306

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: 7306

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: 6966
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: 7306

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 SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am


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