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
 

 

problem with compute

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

New User


Joined: 14 Sep 2007
Posts: 30
Location: Bangalore

PostPosted: Fri May 21, 2010 3:53 pm    Post subject: problem with compute
Reply with quote

I have input value

03 NS-PTP-DAY-1 PIC S9(2)V9(2)
SIGN LEADING SEPARATE.

ANOTHER I/P IS

05 JLPTP-PTP-DAY-1 PIC S9(2)V9(1) USAGE COMP-3.


I need to sum the two values and have result in following format.

WW-SUM-PTP-DAY-1 PIC S9(2)V9 COMP-3 VALUE ZERO.


suppose NS-PTP-DAY-1 = +15.23
JLPTP-PTP-DAY-1 = +10.22 I NEED TO DO

WW-SUM-PTP-DAY-1 = NS-PTP-DAY-1 + JLPTP-PTP-DAY-1


How can i do this. I am getting S0C7. Where am i wrong
Back to top
View user's profile Send private message

icemanroh

New User


Joined: 23 Aug 2008
Posts: 25
Location: Mumbai

PostPosted: Fri May 21, 2010 4:09 pm    Post subject:
Reply with quote

Move NS-PTP-DAY-1 into a Working storage variable which shud have the same PIC clause of the output variable (In ur case its WW-SUM-PTP-DAY-1)

for e.g.

Code:
05 WS-NS-PTP-DAY-1 PIC S9(2)V9(1) USAGE COMP-3.


So in the code:

Code:
MOVE NS-PTP-DAY-1 TO WS-NS-PTP-DAY-1
COMPUTE WW-SUM-PTP-DAY-1 = WS-NS-PTP-DAY-1 + JLPTP-PTP-DAY-1.


Also pls try to do Numeric checks for all the fields before adding them.

Let me know if this works.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8002
Location: Bellevue, IA

PostPosted: Fri May 21, 2010 4:42 pm    Post subject:
Reply with quote

The S0C7 abend means one of your data fields does not contain valid numeric data. You can avoid this by
Code:
IF  NS-PTP-DAY-1 NUMERIC
AND JLPTP-PTP-DAY-1 NUMERIC
    COMPUTE WW-SUM-PTP-DAY-1 = NS-PTP-DAY-1 + JLPTP-PTP-DAY-1
ELSE
    do whatever you want to flag the error
END-IF
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri May 21, 2010 8:35 pm    Post subject:
Reply with quote

Hello,

NUMVAL is very handy if it is guaranteed that the fields will be numeric (i.e. created by an already tested program). NUMVAL is not good for "user input" because if the data is not numeric, the code abends. . .

As much of my "input" data originates on Win-based and UNIX systems, NUMVAL is heavily used.

I keep hoping for an extension to NUMVAL that would intercept the abend and set some "variable" if the value was not numeric. . . Then we could have the ease of use of NUMVAL and protection from the abend icon_smile.gif
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 Strings with double quotes having pro... raja Arumugam IBM Tools 0 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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