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: 8165
Location: East Dubuque, Illinois, 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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am

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