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
 

 

query in rounded phrase in cobol

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

New User


Joined: 24 Jan 2007
Posts: 28
Location: pune

PostPosted: Fri Oct 02, 2009 5:24 pm    Post subject: query in rounded phrase in cobol
Reply with quote

Hi All,

My requirement is as follows.

i/p fileds are of S9(15)V9(02) COMP-3.
O/p field is 9(6).

o/p = (a+b)* 100

In this case , if the value of a and b are equal to 15225.10 and 30450.25 , then the o/p i'm getting is 49%.

The actual division result should be rounded i.e., the percentage i'm expecting is 50%.

My compute statement which i have used is as follows:
COMPUTE o/p ROUNDED =
((a / b) * 100

ON SIZE ERROR
MOVE ZEROES TO o/p
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8121
Location: East Dubuque, Illinois, USA

PostPosted: Fri Oct 02, 2009 5:46 pm    Post subject:
Reply with quote

Another case where intermediate results need to be understood to understand what happened to the fields. Sample code:
Code:
           05  VAR-1                   PIC S9(15)V9(02) COMP-3.
           05  VAR-2                   PIC S9(15)V9(02) COMP-3.
           05  VAR-3                   PIC 9(06).
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           MOVE 15225.10               TO  VAR-1.
           MOVE 30450.25               TO  VAR-2.
           DISPLAY 'VAR-1 ' VAR-1.
           DISPLAY 'VAR 2 ' VAR-2.
           COMPUTE VAR-3 ROUNDED = (VAR-1 / VAR-2) * 100 .
           DISPLAY 'VAR 3 ' VAR-3.
           DISPLAY ' ' .
           COMPUTE VAR-3 ROUNDED = (100 * VAR-1) / VAR-2.
           DISPLAY 'VAR 3 ' VAR-3.
produces output of
Code:
 VAR-1 00000000001522510
 VAR 2 00000000003045025
 VAR 3 000049

 VAR 3 000050
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Sat Oct 03, 2009 7:44 am    Post subject:
Reply with quote

See Appendix A in the Programming Guide for details about intermediate results.
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 XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am


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