Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
poongs
Warnings : 1

New User

Joined: 24 Jan 2007
Posts: 28
Location: pune

 Posted: Fri Oct 02, 2009 5:24 pm    Post subject: query in rounded phrase in cobol 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

Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8280
Location: Dubuque, Iowa, USA

Posted: Fri Oct 02, 2009 5:46 pm    Post subject:

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
Terry Heinze

JCL Moderator

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

 Posted: Sat Oct 03, 2009 7:44 am    Post subject: See Appendix A in the Programming Guide for details about intermediate results.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Linkage editor is part of COBOL, z/OS... ankit.jain COBOL Programming 4 Fri Apr 20, 2018 4:17 pm Difference between EQUAL and EQUAL TO... jithinraghavan COBOL Programming 3 Thu Apr 19, 2018 2:22 am Call COBOL or PLI with a click from w... vaibhav gs All Other Mainframe Topics 1 Mon Apr 16, 2018 7:29 pm COBOL MVS options BiswajitDG COBOL Programming 8 Fri Apr 06, 2018 12:35 am batch cobol/db2 paragraph fall thru a... alois eisshofer COBOL Programming 5 Wed Mar 14, 2018 12:21 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us